Ville M. Vainio | 4 Jul 18:51

Feature: string list 'sort()' method added

Typically, you can't be bothered to remember the flags all the system
commands use for sorting the output. SList.sort() helps here (field 4
is the fifth field, the numeric size):

[docs/howto]|41> a = !ls -l
[docs/howto]|42> a
            <42> SList (.p, .n, .l, .s, .grep(), .fields(), sort() ava
ilable):
0: total 52
1: -rw-r--r-- 1 ville ville  2702 2008-05-15 14:07 html-stylesheets.tx
t
2: -rw-r--r-- 1 ville ville  7301 2008-05-15 14:07 i18n.txt
3: -rw-r--r-- 1 ville ville 16428 2008-05-15 14:07 rst-directives.txt
4: -rw-r--r-- 1 ville ville  8662 2008-05-15 14:07 rst-roles.txt
5: -rw-r--r-- 1 ville ville  5800 2008-05-15 14:07 security.txt
[docs/howto]|43> a.sort(4, nums = True)
            <43> SList (.p, .n, .l, .s, .grep(), .fields(), sort() available):
0: total 52
1: -rw-r--r-- 1 ville ville  2702 2008-05-15 14:07 html-stylesheets.tx
               t
2: -rw-r--r-- 1 ville ville  5800 2008-05-15 14:07 security.txt
3: -rw-r--r-- 1 ville ville  7301 2008-05-15 14:07 i18n.txt
4: -rw-r--r-- 1 ville ville  8662 2008-05-15 14:07 rst-roles.txt
5: -rw-r--r-- 1 ville ville 16428 2008-05-15 14:07 rst-directives.txt
[docs/howto]|44>

I also changed '%cpaste foo' to assign the pasted block to foo as
string list (which is much more useful than just assigning as string).

--

-- 
(Continue reading)

Fernando Perez | 4 Jul 20:55

Re: Feature: string list 'sort()' method added

On Fri, Jul 4, 2008 at 9:55 AM, Ville M. Vainio <vivainio <at> gmail.com> wrote:
> Typically, you can't be bothered to remember the flags all the system
> commands use for sorting the output. SList.sort() helps here (field 4
> is the fifth field, the numeric size):

Nice, thanks!

I'm going to commit some of the testing changes today, let's try to
start putting in tests for all new such features in docstrings.  I'll
work on this now and will ping back later once it's in.

Cheers,

f

Gmane