| View previous topic :: View next topic |
| Author |
Message |
oxygen Voice
Joined: 05 Sep 2005 Posts: 22 Location: Germany
|
Posted: Fri Apr 28, 2006 6:54 am Post subject: Sort database |
|
|
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
Tnx,
~oxygen |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Fri Apr 28, 2006 9:46 am Post subject: |
|
|
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 |
|
 |
oxygen Voice
Joined: 05 Sep 2005 Posts: 22 Location: Germany
|
Posted: Mon May 01, 2006 12:50 pm Post subject: |
|
|
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 |
|
 |
ZeRoMe Voice
Joined: 01 May 2006 Posts: 2 Location: France
|
Posted: Mon May 01, 2006 1:39 pm Post subject: |
|
|
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 |
|
 |
|
|
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
|
|