I have a list of Fruit structs called basket. Each Fruit struct has a name (a string) and a calories (an int
Fruit
basket
name
calories
See Array#sort (API doc). You can pass in a block that returns -1, 0, or 1 given two Fruit objects, and your block can determine these values using whatever attributes you please.
Array#sort