Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

sorting a list of numbers properly.....

Kain Cleaver
Registered User
Join date: 24 Jan 2006
Posts: 178
01-05-2009 21:41
ok.. so ive run into a problem.. i thought something was going to work..but it didnt.. its starting to frustrate me... i need help..

ok.. so say i have a list..
1000,2000,3000,4000,5000,6000,7000,8000,9000,11000

i used llListSort

now my expectations was to have the 11000 list down to 1000...

the problem is.. using list sort it makes 9000 the top number because it begins with 9.. it doesnt take the actual number size into effect.. what do i do?

how do i take a list of numbers and sort them properly from highest to lowest?

actually to be hoenst the list actually lists the number first.. then the key of the person..

like 1000;key 2000;key ect...

but it should still take those numbers into effect first right?
they key of the person has to stay associated with the number

heres what i did.. i know its sloppy... sorry..

sortplayers()
{
players = llListSort(players,1,FALSE);
winner1 = llList2String(players,0);
winner2 = llList2String(players,1);
winner3 = llList2String(players,2);
winner4 = llList2String(players,3);
winner5 = llList2String(players,4);
winner6 = llList2String(players,5);
winner7 = llList2String(players,6);
winner8 = llList2String(players,7);
winner9 = llList2String(players,8);
winner10 = llList2String(players,9);
w1 = llParseString2List(winner1,[";"],[]);
w2 = llParseString2List(winner2,[";"],[]);
w3 = llParseString2List(winner3,[";"],[]);
w4 = llParseString2List(winner4,[";"],[]);
w5 = llParseString2List(winner5,[";"],[]);
w6 = llParseString2List(winner6,[";"],[]);
w7 = llParseString2List(winner7,[";"],[]);
w8 = llParseString2List(winner8,[";"],[]);
w9 = llParseString2List(winner9,[";"],[]);
w10 = llParseString2List(winner10,[";"],[]);
namek1 = llList2Key(w1,0);
score1 = llList2Integer(w1,1);
namek2 = llList2Key(w2,0);
score2 = llList2Integer(w2,1);
namek3 = llList2Key(w3,0);
score3 = llList2Integer(w3,1);
namek4 = llList2Key(w4,0);
score4 = llList2Integer(w4,1);
namek5 = llList2Key(w5,0);
score5 = llList2Integer(w5,1);
namek6 = llList2Key(w6,0);
score6 = llList2Integer(w6,1);
namek7 = llList2Key(w7,0);
score7 = llList2Integer(w7,1);
namek8 = llList2Key(w8,0);
score8 = llList2Integer(w8,1);
namek9 = llList2Key(w9,0);
score9 = llList2Integer(w9,1);
namek10 = llList2Key(w10,0);
score10 = llList2Integer(w10,1);
name1 = llKey2Name(namek1);
name2 = llKey2Name(namek2);
name3 = llKey2Name(namek3);
name4 = llKey2Name(namek4);
name5 = llKey2Name(namek5);
name6 = llKey2Name(namek6);
name7 = llKey2Name(namek7);
name8 = llKey2Name(namek8);
name9 = llKey2Name(namek9);
name10 = llKey2Name(namek10);
nm1p1 = llGetSubString(name1, 0, 9);
nm1p2 = llGetSubString(name1, 10, 19);
nm2p1 = llGetSubString(name2, 0, 9);
nm2p2 = llGetSubString(name2, 10, 19);
nm3p1 = llGetSubString(name3, 0, 9);
nm3p2 = llGetSubString(name3, 10, 19);
nm4p1 = llGetSubString(name4, 0, 9);
nm4p2 = llGetSubString(name4, 10, 19);
nm5p1 = llGetSubString(name5, 0, 9);
nm5p2 = llGetSubString(name5, 10, 19);
nm6p1 = llGetSubString(name6, 0, 9);
nm6p2 = llGetSubString(name6, 10, 19);
nm7p1 = llGetSubString(name7, 0, 9);
nm7p2 = llGetSubString(name7, 10, 19);
nm8p1 = llGetSubString(name8, 0, 9);
nm8p2 = llGetSubString(name8, 10, 19);
nm9p1 = llGetSubString(name9, 0, 9);
nm9p2 = llGetSubString(name9, 10, 19);
nm10p1 = llGetSubString(name10, 0, 9);
nm10p2 = llGetSubString(name10, 10, 19);
llMessageLinked(12, DISPLAY_STRING,nm1p1, "";);
llMessageLinked(13, DISPLAY_STRING,nm1p2, "";);
llMessageLinked(2, DISPLAY_STRING,(string)score1, "";);

llMessageLinked(14, DISPLAY_STRING,nm2p1, "";);
llMessageLinked(15, DISPLAY_STRING,nm2p2, "";);
llMessageLinked(3, DISPLAY_STRING,(string)score2, "";);

llMessageLinked(16, DISPLAY_STRING,nm3p1, "";);
llMessageLinked(17, DISPLAY_STRING,nm3p2, "";);
llMessageLinked(4, DISPLAY_STRING,(string)score3, "";);

llMessageLinked(18, DISPLAY_STRING,nm4p1, "";);
llMessageLinked(19, DISPLAY_STRING,nm4p2, "";);
llMessageLinked(5, DISPLAY_STRING,(string)score4, "";);

llMessageLinked(20, DISPLAY_STRING,nm5p1, "";);
llMessageLinked(21, DISPLAY_STRING,nm5p2, "";);
llMessageLinked(6, DISPLAY_STRING,(string)score5, "";);

llMessageLinked(22, DISPLAY_STRING,nm6p1, "";);
llMessageLinked(23, DISPLAY_STRING,nm6p2, "";);
llMessageLinked(7, DISPLAY_STRING,(string)score6, "";);

llMessageLinked(24, DISPLAY_STRING,nm7p1, "";);
llMessageLinked(25, DISPLAY_STRING,nm7p2, "";);
llMessageLinked(8, DISPLAY_STRING,(string)score7, "";);

llMessageLinked(26, DISPLAY_STRING,nm8p1, "";);
llMessageLinked(27, DISPLAY_STRING,nm8p2, "";);
llMessageLinked(9, DISPLAY_STRING,(string)score8, "";);

llMessageLinked(28, DISPLAY_STRING,nm9p1, "";);
llMessageLinked(29, DISPLAY_STRING,nm9p2, "";);
llMessageLinked(10, DISPLAY_STRING,(string)score9, "";);

llMessageLinked(30, DISPLAY_STRING,nm10p1, "";);
llMessageLinked(31, DISPLAY_STRING,nm10p2, "";);
llMessageLinked(11, DISPLAY_STRING,(string)score10, "";);
}
SuezanneC Baskerville
Forums Rock!
Join date: 22 Dec 2003
Posts: 14,229
01-05-2009 21:51
Are the numbers in the list integers, floats, or strings?
_____________________
-

So long to these forums, the vBulletin forums that used to be at forums.secondlife.com. I will miss them.

I can be found on the web by searching for "SuezanneC Baskerville", or go to

http://www.google.com/profiles/suezanne

-

http://lindenlab.tribe.net/ created on 11/19/03.

Members: Ben, Catherine, Colin, Cory, Dan, Doug, Jim, Philip, Phoenix, Richard,
Robin, and Ryan

-
Kain Cleaver
Registered User
Join date: 24 Jan 2006
Posts: 178
01-05-2009 21:55
the item comes in as a string and gets added to the list.

so the string will be like

12345;(playerkey)

so it will be added to the list players = players + string

after 10 messages come in the list sorts them with the script you see above

even thou i have a problem sorting the numbers.. im even more confused now how ill keep the keys with the corosponding numbers they came in with.. i was hoping the list sort was going to be the easy way in
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
01-05-2009 22:10
hmm, i know with vectors it has trouble converting strings to vectors when using llList2Vector, the work around for that is (vector)llList2String.....convert the list entry back to a string and cast it into a vector.......

you may need to do the same thing for the integer.....
........(integer)llList2String.....etc
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Kain Cleaver
Registered User
Join date: 24 Jan 2006
Posts: 178
01-05-2009 22:21
ok i think i got it.. so what i did .. is at each reception of the string .. i seperated the message into a string and an integer.. and then placed them in as a string and an integer insted of a string.

then i strided the list by 2

if you sort the list as integers.. it sorts properly..
if your sort them as string.. they sort by first number..
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
01-05-2009 22:42
that's good, but does it sort the names with it?
_____________________
Dark Heart Emporium

http://www.xstreetsl.com/modules.php?name=Marketplace&MerchantID=133020

want more layers for tattoos, specifically for the head? vote here
http://jira.secondlife.com/browse/VWR-1449?

llDetectedCollision* Functions similar to touch
http://jira.secondlife.com/browse/SVC-3369
Kain Cleaver
Registered User
Join date: 24 Jan 2006
Posts: 178
01-06-2009 17:50
From: Ruthven Willenov
that's good, but does it sort the names with it?


yes if you sort it with a stride of 2.. it basicly sorts every other with the one next to it..