Eliteofdelete
Member
How do I utilize it effectively? It sorts only the keys but not change the values which seems to make it not very useful.
Here is an example of how I am trying to use it.
It gives
It sorts the keys how I want them but it doesn't match them with the correct output. So, I decided to make a copy of the map, sort that, then put its sorted keys into the original map which would give me the outputs in a sorted fashion.
It gave
Which is not what I wanted, it sorted both maps even tho I said to only sort test2. Not sure why it did that and not sure how to use the command effectively.
Here is an example of how I am trying to use it.
Code:
int[item] test;
for x from 1 to 5
test[to_item(x)]=x;
print("Map Reference:", "orange");
foreach it in test
print(test[it]+": "+it, "blue");
print("");
sort test by -value;
foreach it in test
print(test[it]+": "+it, "blue");
It gives
Code:
Map Reference:
3: helmet turtle
5: pasta spoon
2: seal tooth
1: seal-clubbing club
4: turtle totem
5: helmet turtle
4: pasta spoon
3: seal tooth
2: seal-clubbing club
1: turtle totem
It sorts the keys how I want them but it doesn't match them with the correct output. So, I decided to make a copy of the map, sort that, then put its sorted keys into the original map which would give me the outputs in a sorted fashion.
Code:
int[item] test;
int[item] test2;
for x from 1 to 5
test[to_item(x)]=x;
print("Map Reference:", "orange");
foreach it in test
print(test[it]+": "+it, "blue");
print("");
test2 = test;
sort test2 by -value;
print("Map Test1:", "orange");
foreach it in test
print(test[it]+": "+it, "blue");
print("");
print("Map Test2--Sorted:", "orange");
foreach it in test
print(test2[it]+": "+it, "blue");
It gave
Code:
Map Reference:
3: helmet turtle
5: pasta spoon
2: seal tooth
1: seal-clubbing club
4: turtle totem
Map Test1:
5: helmet turtle
4: pasta spoon
3: seal tooth
2: seal-clubbing club
1: turtle totem
Map Test2--Sorted:
5: helmet turtle
4: pasta spoon
3: seal tooth
2: seal-clubbing club
1: turtle totem
Which is not what I wanted, it sorted both maps even tho I said to only sort test2. Not sure why it did that and not sure how to use the command effectively.
