Here you can find the source of sortStringList(String[] listToSort, String[] priorityList)
public static String[] sortStringList(String[] listToSort, String[] priorityList)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; public class Main { public static String[] sortStringList(String[] listToSort, String[] priorityList) { List<String> list = new ArrayList<>(); // First parse for (String item : listToSort) { if (isSupported(priorityList, item)) { list.add(item);/*from ww w . j ava 2s . co m*/ } } // Second parse for (String item : listToSort) { if (!isSupported(priorityList, item)) { list.add(item); } } return list.toArray(new String[list.size()]); } public static boolean isSupported(String[] list, String test) { for (String item : list) { if (test.contains(item)) { return true; } } return false; } }