I am trying to solve a typical 0/1 knapsack problem (using greedy algorithm). In this problem I have to sort a structure consisting of 2 ints (one that contains the value and their corresponding amount I have to minimize the value to get `n' amounts so i need to sort) I am not able to do so.Please help me out.

Please tell me if there exist any better coding method to solve greedy knapsack problem.