Ben Racine i3enha...@gmail.com writes:
I have a list...
['dir_0_error.dat', 'dir_120_error.dat', 'dir_30_error.dat',
'dir_330_error.dat']
I want to sort it based upon the numerical value only.
Does someone have an elegant solution to this?
I use code like the hack below to sort
On Apr 9, 8:52 am, Ben Racine i3enha...@gmail.com wrote:
I have a list...
['dir_0_error.dat', 'dir_120_error.dat', 'dir_30_error.dat',
'dir_330_error.dat']
I want to sort it based upon the numerical value only.
Does someone have an elegant solution to this?
This approach doesn't rely on
alex23 wrote:
On Apr 9, 8:52 am, Ben Racine i3enha...@gmail.com wrote:
I have a list...
['dir_0_error.dat', 'dir_120_error.dat', 'dir_30_error.dat',
'dir_330_error.dat']
I want to sort it based upon the numerical value only.
Does someone have an elegant solution to this?
This approach
MRAB pyt...@mrabarnett.plus.com wrote:
The string module still exists in Python 3.x, but the string functions
which have been superseded by string methods have been removed.
Awesome, thanks for the heads up.
--
http://mail.python.org/mailman/listinfo/python-list
On Apr 9, 1:58 am, Chris Rebert c...@rebertia.com wrote:
On Thu, Apr 8, 2010 at 4:01 PM, Joaquin Abian gatoyga...@gmail.com wrote:
On Apr 9, 12:52 am, Ben Racine i3enha...@gmail.com wrote:
I have a list...
['dir_0_error.dat', 'dir_120_error.dat', 'dir_30_error.dat',
'dir_330_error.dat']
How about a one liner?
L.sort(key=lambda s: int(s.split('_')[1]))
(Which is not necessarily elegant, but it is short.)
I grant it a measure of elegance as well.
--
http://mail.python.org/mailman/listinfo/python-list
I have a list...
['dir_0_error.dat', 'dir_120_error.dat', 'dir_30_error.dat',
'dir_330_error.dat']
I want to sort it based upon the numerical value only.
Does someone have an elegant solution to this?
Thanks,
Ben R.
--
http://mail.python.org/mailman/listinfo/python-list
On Thu, Apr 8, 2010 at 3:52 PM, Ben Racine i3enha...@gmail.com wrote:
I have a list...
['dir_0_error.dat', 'dir_120_error.dat', 'dir_30_error.dat',
'dir_330_error.dat']
I want to sort it based upon the numerical value only.
a = ['dir_0_error.dat', 'dir_120_error.dat', 'dir_30_error.dat',
Ben Racine wrote:
I have a list...
['dir_0_error.dat', 'dir_120_error.dat', 'dir_30_error.dat',
'dir_330_error.dat']
I want to sort it based upon the numerical value only.
Does someone have an elegant solution to this?
Thanks,
Ben R.
How about a one liner?
L.sort(key=lambda s:
On Apr 9, 12:52 am, Ben Racine i3enha...@gmail.com wrote:
I have a list...
['dir_0_error.dat', 'dir_120_error.dat', 'dir_30_error.dat',
'dir_330_error.dat']
I want to sort it based upon the numerical value only.
Does someone have an elegant solution to this?
Thanks,
Ben R.
not sure
On 04/09/10 08:52, Ben Racine wrote:
I have a list...
['dir_0_error.dat', 'dir_120_error.dat', 'dir_30_error.dat',
'dir_330_error.dat']
I want to sort it based upon the numerical value only.
Does someone have an elegant solution to this?
Thanks,
Ben R.
list.sort() and sorted()
On Thu, Apr 8, 2010 at 4:01 PM, Joaquin Abian gatoyga...@gmail.com wrote:
On Apr 9, 12:52 am, Ben Racine i3enha...@gmail.com wrote:
I have a list...
['dir_0_error.dat', 'dir_120_error.dat', 'dir_30_error.dat',
'dir_330_error.dat']
I want to sort it based upon the numerical value only.
12 matches
Mail list logo