Write a function sorting(L).

bartc bc at freeuk.com
Fri Apr 21 17:15:38 EDT 2017


On 21/04/2017 21:04, Mohammed Ahmed wrote:
> On Friday, April 21, 2017 at 10:02:55 PM UTC+2, Chris Angelico wrote:
>> On Sat, Apr 22, 2017 at 5:58 AM, Mohammed Ahmed <moh.ahm1166 at gmail.com> wrote:
>>> Write a function sorting(L) that takes a list of numbers and returns the list with all
>>> elements sorted in ascending order.
>>> Note: do not use the sort built in function
>>>
>>> it is a python question
>>
>> Yes, it is. It looks like the sort of question that you're supposed to
>> try to answer in order to learn how to write software. I suggest you
>> try to answer it.
>>
>> ChrisA
>
> i tried a lot but i can't answer it so i thought of getting some help here

You need an algorithm.

How would you sort a set of numbered cards? I might start with looking 
for the smallest, and either moving that to the front, or using it to 
build a new set.

(It's not clear from the question whether the list needs to be sorted 
in-place, or a new list is returned with the elements sorted.)

-- 
bartc



More information about the Python-list mailing list