I have seen compare function in sort to sort using the second element and all! But i am not understanding the syntax. Can anyone please provide the syntax to sort the pairs by the sum of the elements or product of the elements so that i will get the idea of the compare function Thanks in advance! asked 26 Aug '14, 22:47

Well the general syntax of the sort() function is sort(start,end,overload function); where the "overload function" is the one we provide to overload the original function of the c++. As for sorting by sum or product just write a overload function as:
answered 27 Aug '14, 00:31

answered 26 Oct '14, 21:47
