Pergunta de entrevista da empresa RetailMeNot

Simple question involving sorting a list and summing it to a certain point.