1) Your function is
2) I think what you are trying to do is sort it so the lowest element goes to the front, then sort the rest of the list. So when you recursively call the sort again on line 9, I think you need to start from the beginning (of the now shorter list). So the
3) On line 9 sortlist returns a list. On line 3 sortlist returns an element of a list (probably a str the way you've used it). By returning different things, this complicates stuff. I recommend making it always return a list.
4) on line 9 you add two things together. The first is
return()
ing information to the caller, but the main program ignores the data that is returned. It just prints the original lst
object. If that information isn't necessary, then why are the return statements there? You should be printing the information you got from the function, not the data you called it with. Or you should make sure the function properly sorts the called list (but I don't think it's written to do that).2) I think what you are trying to do is sort it so the lowest element goes to the front, then sort the rest of the list. So when you recursively call the sort again on line 9, I think you need to start from the beginning (of the now shorter list). So the
i
needs to be reset to zero for that call.3) On line 9 sortlist returns a list. On line 3 sortlist returns an element of a list (probably a str the way you've used it). By returning different things, this complicates stuff. I recommend making it always return a list.
4) on line 9 you add two things together. The first is
[lst[0]]
. This is a list you create with a single element in it. The second is [sortlist(...)]
. With step 3 above, this should always be a list. This means you're creating sublists. I think you mean to do something similar to return [lst[0]] + sortlist(...)
.