From: <ma...@la...> - 2001-02-23 12:46:35
|
Adam Burke <ada...@gb...> said: > The JPython mailing list is technically retired now, I've copied > jython-users. > > sort() changes the state of the list so that it's sorted. > > >>> x = [ 'e', 'a', 'y', 'k', 'l' ] > >>> print x > ['e', 'a', 'y', 'k', 'l'] > >>> x.sort() > >>> print x > ['a', 'e', 'k', 'l', 'y'] > > If you want to keep the unsorted data you need to take a copy, ie, y = x. Careful: y = x doesn't make a copy, it just assigns another name for the same list. Use y = x[:] to make a copy. |