Hi, I'm looking for where either the sort module or the sorted() function resides.
I'm thinking a module in the default folders, but have no idea where it is, or how to locate it (sorted is in the path, but I don't know how to display a parent based of its function)
Also, if this is in a module/group of built in functions, I would like to know that file aswell.
The reason is I'm trying to learn how for example sorted() works (so I could build my own instead of using the built in) for knowledge's sake. I could ask for how it works, but knowing how to find multiple functions would be better.
Thanks a bunch
-Brandon
Jadellll 0 Newbie Poster
Recommended Answers
Jump to PostPutting in a temporary test print line might just help you better understand what is going on ...
def bubble_sort(list1): # make true copy of list1 so there is no feedback list1 = list(list1) for i in xrange(len(list1) - 1, 0, -1): print list1 # a test …
Jump to Postyeah I think I'm getting it now. The first for loop finds each element in reverse order. The second tests that elements vs each other element. If its greater, the smaller one goes to j-1, if its bigger, it goes to j. right?
Yes, you got the hang of it!
…
All 6 Replies
bumsfeld 413 Nearly a Posting Virtuoso
Jadellll 0 Newbie Poster
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
Jadellll 0 Newbie Poster
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
Jadellll 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.