let's assume I have a basket of 4 different kinds of fruits (Apples, Oranges, Bananas, Pears).
tell me the number (n) of each fruit that I have.
If my basket is full, I would like to sell the rest of the fruits that I do not need. However, every fruit has a different value (price = p). Let's say
p_a = 4
p_o = 2
p_b = 1
p_p = 0
Let's say, I have x too many fruits, so
Now, I would first like to sell the ones, I get the most value from (I can only sell as many as I have). If toomanyfruits is still > 0, I would like to sell the ones which are second most valuable etc. pp..
So, I tried to use the command sort, but I have the problem that I do not need the sorted values, but the names of that fruit which has the highest value to be able to then call it for ranking. I tried some different things, but do not seem to get the right thing.
Some help would be highly appreciated :-)
With kind regards