DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Sorted For Python Before 2.4

06.22.2005
| 3165 views |
  • submit to reddit
        
def sorted(seq):
  seq.sort()
  return seq
    

Comments

Snippets Manager replied on Mon, 2012/05/07 - 2:12pm

That will change the sequence you pass to it while 2.4's sorted() will not. Here's a more accurate version: def sorted(seq): newseq = seq[:] newseq.sort() return newseq