Java tutorial
//package com.java2s; //License from project: Apache License import java.lang.management.ThreadInfo; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.List; public class Main { private static List<ThreadInfo> sort(ThreadInfo[] dumpAllThreads) { List<ThreadInfo> allThreads = new ArrayList<ThreadInfo>(Arrays.asList(dumpAllThreads)); Collections.sort(allThreads, new Comparator<ThreadInfo>() { @Override public int compare(ThreadInfo o1, ThreadInfo o2) { return o1.getThreadName().compareTo(o2.getThreadName()); } }); return allThreads; } }