mIRC Home    About    Download    Register    News    Help

Print Thread
#67960 15/01/04 05:40 PM
Joined: Oct 2003
Posts: 37
B
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Oct 2003
Posts: 37
I have a list of stuff I want to sort solely by the first column, but using filter -t also seems to alphabetize by the 3rd column...

What's the fastest way to make it sort only by the first column and ignore the rest...

-eMpTy

#67961 15/01/04 05:50 PM
Joined: Feb 2003
Posts: 282
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Feb 2003
Posts: 282
/filter -a

#67962 15/01/04 10:25 PM
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
Try this example:

//window -e @win | echo @win d b c | echo @win c a b | echo @win a d a | echo @win b c d | filter -twwc 1 32 @win @win

Here the lines are sorted by the first word. If your "columns" are separated by $chr(9) - TAB - use "-t 1 9" instead of "-t 1 32".

#67963 17/01/04 05:43 AM
Joined: Oct 2003
Posts: 37
B
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Oct 2003
Posts: 37
filter -tffc 1 9 $+(",$scriptdir,AGwaiting.ini,") $+(",$scriptdir,AGwaiting.ini,") *

Here's the line I'm using, and it sorts by everything...I tried using -a, but even the simplest alias I can come up with takes twice as much time as the straight filter...

Am I doing something wrong here???

-eMpTy

#67964 17/01/04 06:22 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
the problem is it doenst just sort on the column you specifiy its that column and onwards, im assuming for you column 2 all look the same , else you would have noticed it was sorting on that as well as column 3, i suggest using -a heres a sample script..

filter -wwa @in @out column.1.sorter *

alias column.1.sorter {
var %v1,%v2
%v1 = $gettok($1,1,32)
%v2 = $gettok($2,1,32)
$iif(%v1 == %v2,return 0)
return $iif(%v1 < %v2,-1,1)
}

This well give you a sorted list based just on the column (tok)number you select in the $gettok , change the token seperator if its not space (32).

As a note, it appears to leave the order of the entries the same ecept for the column you have sorted on, ie if u had

b x 9
c x 3
c x 4
b x 6
c x 1

you end up with

b x 9
b x 6
c x 3
c x 4
c x 1

but i have watched how it sorts them, its not using a bubble sort (which would be real slow) loooks like a divisiopn by two sort, with insertion rather than swaping high and lower values, so saying this....
I would not always count on the other columns to remain in the order they appeared pre sort, it might be the case but it might not be.


Link Copied to Clipboard