Here you can find the source of radixSort(int[] vs)
public static void radixSort(int[] vs)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { public static void radixSort(int[] vs) { int n = vs.length; int[] us = new int[n]; int[] num = new int[1 << 8]; for (int i = 0; i < n; i++) vs[i] ^= 1 << 31;//from w ww . ja v a 2s .c om for (int i = 0; i < 32; i += 8) { Arrays.fill(num, 0); for (int j = 0; j < n; j++) { num[vs[j] >>> i & 0xff]++; } for (int j = 0; j < num.length - 1; j++) num[j + 1] += num[j]; for (int j = n - 1; j >= 0; j--) { int p = vs[j] >>> i & 0xff; us[--num[p]] = vs[j]; } int[] t = vs; vs = us; us = t; } for (int i = 0; i < n; i++) vs[i] ^= 1 << 31; } public static void radixSort(long[] vs) { int n = vs.length; long[] us = new long[n]; int[] num = new int[1 << 8]; for (int i = 0; i < n; i++) vs[i] ^= 1L << 63; for (int i = 0; i < 64; i += 8) { Arrays.fill(num, 0); for (int j = 0; j < n; j++) { num[(int) (vs[j] >>> i & 0xff)]++; } for (int j = 0; j < num.length - 1; j++) num[j + 1] += num[j]; for (int j = n - 1; j >= 0; j--) { int p = (int) (vs[j] >>> i & 0xff); us[--num[p]] = vs[j]; } long[] t = vs; vs = us; us = t; } for (int i = 0; i < n; i++) vs[i] ^= 1L << 63; } public static void fill(int[][] A, int a) { for (int i = 0; i < A.length; i++) Arrays.fill(A[i], a); } }