I was trying to create a simple script to find out how much of each item I owned, and I'm not sure I understand 'sort' (I read through the thread linked in the wiki and it didn't help me). This example gives odd results... and quantities of things I know I don't own. I think this is sorting the keys and not values, or vice versa... or maybe both. Could you guys tell me what's wrong with my script? Once I understand, I'll add this as an example to the wiki.
Code:
int[item] whatGot; // what do I own
foreach it in get_inventory() {
int num = item_amount(it);
whatGot[it] = num;
}
sort whatGot by value;
foreach it in whatGot {
print(whatGot[it] + ' of ' + it);
}
print_html('<b>Done!</b>');