Here you can find the source of sortMessages(List
@SuppressWarnings("rawtypes") private static void sortMessages(List<Hashtable> ms)
//package com.java2s; /**// www .jav a 2 s .co m * Copyright 2009 Welocalize, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ import java.util.Collections; import java.util.Comparator; import java.util.Hashtable; import java.util.List; public class Main { @SuppressWarnings("rawtypes") private static void sortMessages(List<Hashtable> ms) { Collections.sort(ms, new Comparator<Hashtable>() { @Override public int compare(Hashtable o1, Hashtable o2) { Integer n1 = (Integer) o1.get("sortPriority"); if (n1 == null) n1 = 3; Integer n2 = (Integer) o2.get("sortPriority"); if (n2 == null) n2 = 3; int k = n1 - n2; if (k != 0) return k; long d1 = (Long) o1.get("sortTime"); long d2 = (Long) o2.get("sortTime"); k = (int) (d1 - d2); if (k != 0) return k; int axis1 = (Integer) o1.get("sortAxis"); int axis2 = (Integer) o2.get("sortAxis"); return (int) (axis1 - axis2); } }); } }