The code is as follows:
Import Java.util.arrays;public class Multikeyradixsort {public static void Radixsort (int [] data, int radix, int d) {System . OUT.PRINTLN ("Start sort:"); int length = data.length;//requires a temporary array int [] tmp = new int [length];//buckets array is bucket sort must buckets array int[] Buckets = new int[radix];//treats sorted data sequentially from the highest-level sub-keywords//The following loop in which the rate is used to hold the current computed bits (such as 10-bit time rate =10) for (int i = 0, rate = 1;i < D i++) {//Resets the count array to start counting the second keyword Arrays.fill (buckets, 0); Copies the elements of the data array into the temporary array for caching system.arraycopy (data, 0, tmp, 0, length); Computes the sub-key for each data to be sorted for (int j = 0;j < length;j++) {//the keyword int subkey = (tmp[j]/rate) at the specified position of the calculated data % Radix; buckets[subkey]++; } for (int j = 1;j < Radix; J + +) {Buckets[j] = Buckets[j] + buckets[j-1]; Sort specified data by sub-keyword for (int m = length-1;m >=0;m--) {int subkey = (tmp[m]/rate)% Radix; Data[--buckets[subkey]] = tmp[m]; } SYSTEM.OUT.PRintln ("+rate+" bit on sub-keywords: "+ java.util.Arrays.toString (data)"); Rate *= Radix; }}public static void Main (string[] args) {int[] data = {1100,192,221,12,13}; System.out.println ("before sorting: \ n" + java.util.Arrays.toString (data)); Radixsort (data,10,4); System.out.println ("After sorting: \ n" + java.util.Arrays.toString (data));}}
Java Cardinality Ordering