[Baypiggies] sorting alphanumeric list

Tony Godshall tony at godshall.org
Tue Jul 19 21:36:49 CEST 2011


On Tue, Jul 19, 2011 at 12:12 PM, Vikram K <kpguy1975 at gmail.com> wrote:
> given the following list:
>
>>>> a
> ['Y6', 'T5']
>
> how do i modify list a to end up with:
>
>>>> b
> ['T5', 'Y6']
>
> of course my actual data consists of nested lists whose elements consist of
> lists like list a.


tony at d6:~$ python
Python 2.6.6 (r266:84292, Dec 27 2010, 00:02:40)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> a=['Y6', 'T5']
>>> b=a[:]
>>> b.sort()
>>> b
['T5', 'Y6']
>>> a
['Y6', 'T5']


More information about the Baypiggies mailing list