Python Forum

Full Version: Write a function sorting(L)?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
my question here
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
my code here
what have you tried?
to sort list, it's
listname.sort()
i think i could not use this
(Apr-21-2017, 07:52 PM)MoIbrahim Wrote: [ -> ]i think i could not use this

I would assume so.  Anyway, you need to show us an attempt.

My assumption is that your instructor probably expects you to implement bubble or insertion sort:  
https://en.wikipedia.org/wiki/Sorting_algorithm
(Apr-21-2017, 07:48 PM)Larz60+ Wrote: [ -> ]what have you tried? to sort list, it's
listname.sort()
i think i can't use this
(Apr-21-2017, 07:54 PM)Mekire Wrote: [ -> ]I would assume so.  Anyway, you need to show us an attempt.
def sorting(items):
    return sorted(items)
ezpz
(Apr-21-2017, 08:05 PM)nilamo Wrote: [ -> ]
def sorting(items): return sorted(items) 
ezpz
thank you but i can't use that
Your thread is going to end up locked in a second. You have been told you need to make an honest attempt. I gave you a link to sorting algorithms. I told you which ones to look at. Make an attempt and THEN reply.
What have you tried so far? We can keep making jokes all day, but we're not going to write it for you.
If you just want an answer, go to wikipedia and copy-paste their quicksort example.
Pages: 1 2