sorting a list
P at draigBrady.com
P at draigBrady.com
Wed Mar 10 08:10:16 EST 2004
ketulp_baroda at yahoo.com wrote:
> Hi
> I want to sort a list.
> My problem is:
>
>
>>>>a=['a','f','F','A','D']
>>>>a.sort()
>>>>a
>
> ['A','D', 'F', 'a', 'f']
>
>
> But I am actually looking for an output:
> ['A','a','D','F','f']
>
> Is there any module to sort a list this way?
If you want to sort textual data sensitive to
the current user's language do this:
a=['a','f','F','A','D']
import locale
locale.setlocale(locale.LC_ALL,"")
a.sort(locale.strcoll)
--
Pádraig Brady - http://www.pixelbeat.org
More information about the Python-list
mailing list