Octal number problem

Tim Evans t.evans at paradise.net.nz
Fri Feb 21 22:44:41 EST 2003


Gary Duncan <gmduncan at netspace.net.au> writes:

[snip]
> 	I have a list of 5-digit decimal numbers, which was constructed
> with leading zeroes where necessary so that the list is sorted by magnitude
> using Unix 'sort' (otherwise '00200' would appear before '1').

Slightly off-topic, but (at least when using gnu sort) 'sort -n' can
fix that:

$ printf '100\n2' | sort
100
2
$ printf '100\n2' | sort -n
2
100

The '-n' switch sorts the lines as decimal numbers.

-- 
Tim Evans




More information about the Python-list mailing list