fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int cmp(const void *a,const void *b)
  5. {
  6. int A=*(const int*)a,B=*(const int*)b;
  7. return (A>B)-(B>A);
  8. }
  9.  
  10. int main()
  11. {
  12. int tb[][2]={{5,3},{12,4},{5,1},{5,2},{1,1}};
  13. int i;
  14. qsort(&tb[0][0],5,2*sizeof(int),cmp);
  15. for(i=0;i<5;++i) printf("%d %d\n",tb[i][0],tb[i][1]);
  16. return 0;
  17. }
  18.  
Success #stdin #stdout 0s 2248KB
stdin
Standard input is empty
stdout
1 1
5 3
5 1
5 2
12 4