Write a logic to find the median value from an array list. Implement find_median(nums), where nums is a non-empty list of integers, and return the median as a number. For an odd-length list, return the middle value after sorting; for an even-length list, return the average of the two middle values. Example: [7, 1, 3] returns 3, while [1, 2, 3, 4] returns 2.5.
def find_median(nums):