egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Sort database

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
oxygen
Voice


Joined: 05 Sep 2005
Posts: 22
Location: Germany

PostPosted: Fri Apr 28, 2006 6:54 am    Post subject: Sort database Reply with quote

Hello all.

I need some help to sort my database.
My database is formatted like this:
A1,B1,C1,D1 A2,B2,C2,D2 A3,B3,C3,D3 and so on...
Example:
345,nick1,23,56 333,nick2,22,3 200,nick3,4,3
I sort this with:
Code:
set score [lsort -dict -decreasing [split [gets $scorefile]]]

but I want to sort B1 and B2 and B3 or C1 and C2 and C3 to.
How can I sort it that way.
Hope I explained it that somebody can understand it Wink

Tnx,
~oxygen
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Fri Apr 28, 2006 9:46 am    Post subject: Reply with quote

Since you have the -decreasing switch, c3 will come before c2 c1 b3...etc (that's because tha ASCII representation of c is greater than b) so if you remove that switch, the order of the letters will become increasing (from a to z) but the numbers will probably come first (also from least to greatest).
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
oxygen
Voice


Joined: 05 Sep 2005
Posts: 22
Location: Germany

PostPosted: Mon May 01, 2006 12:50 pm    Post subject: Reply with quote

Hello

I'll try to explaine it better. The database is part of a trivia game.
The first item is the yearly score, third item monthly score and so on.
With the above code the database is sorted by the first item, the yearly score. When I do a top 10 then it counts the yearly score. What I want is a top 10 score with the third item, the monthly score. How can I sort the database to do this?

Regards,
~oxygen
Back to top
View user's profile Send private message
ZeRoMe
Voice


Joined: 01 May 2006
Posts: 2
Location: France

PostPosted: Mon May 01, 2006 1:39 pm    Post subject: Reply with quote

To sort correctly your score you must place item in first place, for exemple:
345,nick1,23,56
To order by item 4 (56) place this in first position:
56,345,nick1,23
Use split and lindex commands.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber