lammps-master/src/mergesort.h
static void insertion_sort(int *index, int num, void *ptr,
                           int (*comp)(int, int, void*))
{
  if (num < 2) return;
  for (int i=1; i < num; ++i) {
    int tmp = index[i];
    for (int j=i-1; j >= 0; --j) {
      if ((*comp)(index[j],tmp,ptr) > 0) {
        index[j+1] = index[j];
      } else {
        index[j+1] = tmp;
        break;
      }
      if (j == 0) index[0] = tmp;
    }
  }
}
// part 1. insertion sort for pre-sorting of small chunks
part 1. insertion sort for pre-sorting of small chunks
part 1 . insertion sort for pre - sorting of small chunks
static void insertion_sort(int *index, int num, void *ptr,
                           int (*comp)(int, int, void*))
{
  if (num < 2) return;
  for (int i=1; i < num; ++i) {
    int tmp = index[i];
    for (int j=i-1; j >= 0; --j) {
      if ((*comp)(index[j],tmp,ptr) > 0) {
        index[j+1] = index[j];
      } else {
        index[j+1] = tmp;
        break;
      }
      if (j == 0) index[0] = tmp;
    }
  }
}
static void insertion_sort ( int * index , int num , void * ptr , int ( * comp ) ( int , int , void * ) ) { if ( num < 2 ) return ; for ( int i = 1 ; i < num ; ++ i ) { int tmp = index [ i ] ; for ( int j = i - 1 ; j >= 0 ; -- j ) { if ( ( * comp ) ( index [ j ] , tmp , ptr ) > 0 ) { index [ j + 1 ] = index [ j ] ; } else { index [ j + 1 ] = tmp ; break ; } if ( j == 0 ) index [ 0 ] = tmp ; } } }
part 1. insertion sort for pre-sorting of small chunks
part 1 . insertion sort for pre - sorting of small chunks