4

I am stuck using the older version (2.2.1) of Jython on the machines I am working on, but I need the sorted method. I already import generators from future, but

from __future__ import sorted

returns SyntaxError: future feature sorted is not defined. Is there a module I can import that has it?

TreyE
  • 2,649
  • 22
  • 24
Climbs_lika_Spyder
  • 6,004
  • 3
  • 39
  • 53

1 Answers1

5

If you're stuck with an old version of jython, maybe you should use .sort() instead?

>>> a = [ 3, 1, 4, 1, 5, 9 ]
>>> a.sort()
>>> a
[1, 1, 3, 4, 5, 9]

You could even define your own sorted to replace the missing one:

>>> def my_sorted(a):
...     a = list(a)
...     a.sort()
...     return a
... 
>>> b = [3,1,4,1,5,9]
>>> my_sorted(b)
[1, 1, 3, 4, 5, 9]
>>> b
[3, 1, 4, 1, 5, 9]
rampion
  • 87,131
  • 49
  • 199
  • 315