This code is why you want a hash, not an array. See how you have to loop through everything, rather than doing 

stocks[sold_stock.stock_symbol]

Very different.