Oops, try again. median([4, 5, 5, 4]) returned 5 instead of 4.5

I am unable to understand why the list is not being sorted before it looks any further to find the median. it might be something stupid but I guess I am missing it.

```
def median(lst):
lst_1=sorted(lst)
length=len(lst_1)
for i in lst_1:
if length==1:
return lst[0]
elif length%2!=0:
return lst_1[(length+1)/2]
elif length%2==0:
med1=lst_1[length/2]
med2=lst_1[(length/2)+1]
return (med1+med2)/2
```