You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Ryan Schmidt <su...@ryandesign.com> on 2005/02/06 17:59:27 UTC
Re: svn list - sorting (natural sort)
On 06.02.2005, at 00:46, allan juul wrote:
> is there a way to tweak the sort order of a "svn list URL" ?
>
> our tagging are basically numbers:
>
> module/v_1
> module/v_3
> module/v_20
> module/v_112
>
> the above list will be sorted like this :
>
> module/v_1
> module/v_112
> module/v_20
> module/v_3
>
> it's not the greatest issue, but would sometimes be nice to be able to
> supply a "sort-by" option on the command line.
I think the "Unix way" would be to pipe the output of "svn list URL" to
a separate sorting program.
The man page for "sort" didn't hint at a way to get it to do
natural-order sorting, so here's a PHP script you can pipe your output
through:
#!/usr/local/bin/php
<?php
$lines = array();
while (($line = fgets(STDIN, 1024)) !== false) {
$lines[] = $line;
}
usort($lines, 'strnatcmp');
echo implode($lines, '');
?>
This doesn't have "sort"'s nice ability to specify which
space-delimited field to sort on, but that could of course be added.
You could undoubtedly write a similar script in Perl or Ruby or C or
any other language you like; I just happen to like PHP.
Ways to do this in Perl, Ruby and C are available here:
http://sourcefrog.net/projects/natsort/
(Yes, SourceFrog, not SourceForge.)
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Re: svn list - sorting (natural sort)
Posted by Ryan Schmidt <su...@ryandesign.com>.
On 06.02.2005, at 23:44, Hakan Koseoglu wrote:
>> Instead of the desired naturally-sorted output:
>> module/v_1
>> module/v_3
>> module/v_20
>> module/v_112
>
> GNU sort has -n option to sort numerically. Would that help?
Not that I can see, because as the man page says, it only sorts on an
initial numeric string, not a numeric string later in the line.
Re: svn list - sorting (natural sort)
Posted by Hakan Koseoglu <ha...@gmail.com>.
> Instead of the desired naturally-sorted output:
> module/v_1
> module/v_3
> module/v_20
> module/v_112
GNU sort has -n option to sort numerically. Would that help?
--
Hakan (m1fcj)
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Re: svn list - sorting (natural sort)
Posted by Ryan Schmidt <su...@ryandesign.com>.
On 06.02.2005, at 19:10, Rob Shepherd wrote:
> Ryan Schmidt wrote:
>> I think the "Unix way" would be to pipe the output of "svn list URL"
>> to a separate sorting program.
>> The man page for "sort" didn't hint at a way to get it to do
>> natural-order sorting, so here's a PHP script you can pipe your
>> output through:
>
> unix sort will sort this as you wish by default
>
> svn list URL | sort
On the systems I have access to (Mac OS X, Gentoo, FreeBSD) the
built-in sort program produces this ASCII-sorted output:
module/v_1
module/v_112
module/v_20
module/v_3
Instead of the desired naturally-sorted output:
module/v_1
module/v_3
module/v_20
module/v_112
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Re: svn list - sorting (natural sort)
Posted by Rob Shepherd <ro...@informatics.bangor.ac.uk>.
Ryan Schmidt wrote:
> On 06.02.2005, at 00:46, allan juul wrote:
>
>> is there a way to tweak the sort order of a "svn list URL" ?
>>
>> our tagging are basically numbers:
>>
>> module/v_1
>> module/v_3
>> module/v_20
>> module/v_112
>>
>> the above list will be sorted like this :
>>
>> module/v_1
>> module/v_112
>> module/v_20
>> module/v_3
>>
>> it's not the greatest issue, but would sometimes be nice to be able to
>> supply a "sort-by" option on the command line.
>
>
> I think the "Unix way" would be to pipe the output of "svn list URL" to
> a separate sorting program.
>
> The man page for "sort" didn't hint at a way to get it to do
> natural-order sorting, so here's a PHP script you can pipe your output
> through:
unix sort will sort this as you wish by default
svn list URL | sort
you may find sort from the cygwin environment will work on windows.
Rob
--
/**
* Rob Shepherd,
* University Of Wales, Bangor,
* School of Informatics,
* Dean Street,
* Bangor,
* Gwynedd, UK /\ /\
* LL57 1UT / \/ \ /\
* --------------/---/ \--\----
*
* robshep@informatics.bangor.ac.uk
*
* +44 (0) 1248 38 27
*/