perl多关键字排序 perl逆序


perl多关键字排序 perl逆序
2012年01月19日
  perl reverse sort {} map {} grep {} @a; sort comparator -1 1 0 不稳定排序(快速排序)
  多关键字可以用:
  $ka1$kb1
  or $ka2$kb2
  or $ka3$kb3
  ...
  逆序输出可以用:
  reverse
  private static void mergeSort(Object[] src,
  Object[] dest,
  int low, int high, int off,
  Comparator c) {
  int length = high - low;
  // Insertion sort on smallest arrays
  if (length low && c.compare(dest[j-1], dest[j])>0; j--)
  swap(dest, j, j-1);
  return;
  }
  // Recursively sort halves of dest into src
  int destLow  = low;
  int destHigh = high;
  low  += off;
  high += off;
  int mid = (low + high) >>> 1;
  mergeSort(dest, src, low, mid, -off, c);
  mergeSort(dest, src, mid, high, -off, c);
  // If list is already sorted, just copy from src to dest.  This is an
  // optimization that results in faster sorts for nearly ordered lists.
  if (c.compare(src[mid-1], src[mid]) = high || p < mid && c.compare(src[p], src[q]) <= 0)
  dest[i] = src[p++];
  else
  dest[i] = src[q++];
  }
  }

猜你喜欢

转载自mxoq16mxoq.iteye.com/blog/1364507