fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. #define N 21
  5.  
  6. int main() {
  7. int seq[N] = {-4, -7, -1, 4, -6, 1, -5, 5, 2, 9, -3, 8, 3, 7, -8, 6, -9, -10, 0, -2, 10};
  8.  
  9. qsort(seq, N, sizeof(seq[0]),(int (*)(const void *, const void *))({
  10. int hi_im_lambda (const int* x, const int* y) { return abs(*x) - abs(*y); }
  11. hi_im_lambda;
  12. }));
  13.  
  14. unsigned i;
  15. for (i = 0; i < N; ++i)
  16. printf("%3d\n", seq[i]);
  17.  
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0s 2008KB
stdin
Standard input is empty
stdout
  0
 -1
  1
  2
 -2
 -3
  3
 -4
  4
 -5
  5
 -6
  6
 -7
  7
  8
 -8
  9
 -9
-10
 10