Updated sorting for values & weights, debugged sort()