Here you can find the source of sortNames(String[] names)
private static String[] sortNames(String[] names)
//package com.java2s; //License from project: Open Source License public class Main { private static String[] sortNames(String[] names) { String[] newOrder = new String[] { "labelx", "labels1", "labels2", "labels3" }; String[] sortedNames = new String[names.length]; int index = 0; for (String newOrderName : newOrder) { for (String name : names) { if (name.equals(newOrderName)) { sortedNames[index++] = name; }//from www . j av a2s . c om } } return sortedNames; } }