How to sort?

So I wrote this script, which works but is highly ineffecient.

I want to sort all the quantities of garnishes I own, and create 10 of the item I have the
least of using the still.

Any ways to really simplify and improve this script would be appreciated!
 

Attachments

  • 1.Wakeup.ash
    4.8 KB · Views: 37

Bale

Minion
It seems that you're unaware of the amazingly powerful sort command and don't know how to fully utilize maps.

PHP:
item [item] transform;
transform [$item[cocktail onion]] = $item[olive];
transform [$item[kiwi]] = $item[lemon];
transform [$item[kumquat]] = $item[orange];
transform [$item[tangerine]] = $item[grapefruit];
transform [$item[tonic water]] = $item[soda water];
transform [$item[raspberry]] = $item[strawberry];

item [int] garnish;
foreach key in transform
	garnish [count(garnish)] = key;

sort garnish by item_amount(value);

create(stills_available(),garnish[0]);
 
Last edited:
Top