struct muchie{ int x, y, cost;};muchie a[1000];
#include<algorithm>using namespace std...inline bool cmp( muchie A, muchie B ){ return A.cost<B.cost;}...int main(){...sort( a, a+N, cmp ) // unde N este nr de elemente din a[], cmp este functia de comparare a doua elemente din a[] ( evident poti sa adaugi mai multe criterii )...}
inline bool cmp (const muchie &a, const muchie &b) { return a.cost < b.cost;}
struct cmp { bool operator()(const muchie &a, const muchie &b) const { return a.cost < b.cost; } };