Here you can find the source of int2sortableStr(int val)
public static String int2sortableStr(int val)
//package com.java2s; //License from project: Apache License public class Main { public static String int2sortableStr(int val) { char[] arr = new char[3]; int2sortableStr(val, arr, 0); return new String(arr, 0, 3); }//ww w . ja v a2s . c o m public static String int2sortableStr(String val) { return int2sortableStr(Integer.parseInt(val)); } public static int int2sortableStr(int val, char[] out, int offset) { val += Integer.MIN_VALUE; out[offset++] = (char) (val >>> 24); out[offset++] = (char) ((val >>> 12) & 0x0fff); out[offset++] = (char) (val & 0x0fff); return 3; } }