Use a custom comparator:
Collections.sort(nodeList, new Comparator<DataNode>(){
public int compare(DataNode o1, DataNode o2){
if(o1.degree == o2.degree)
return 0;
return o1.degree < o2.degree ? -1 : 1;
}
});
More Related Contents:
- Heavy numbers calculation in Java
- Writing to a file errors – Android Studio
- Java 8 Functional interface method name not required
- Actual and formal argument lists differ in length Java
- How does the Java ‘for each’ loop work?
- How to wait for all threads to finish, using ExecutorService?
- JUnit test for System.out.println()
- Display Animated GIF
- Sort a two dimensional array based on one column
- Swing rendering appears broken in JDK 1.8, correct in JDK 1.7
- JTable not showing up on JFrame (Java)
- Converting Roman Numerals To Decimal
- Error:Execution failed for task ‘:app:dexDebug’. com.android.ide.common.process.ProcessException
- Why can’t we use ‘this’ keyword in a static method
- Smoothing a jagged path
- What is the difference between Double.parseDouble(String) and Double.valueOf(String)?
- Help with packages in java – import does not work
- How to open a Windows named pipe from Java?
- Grab a segment of an array in Java without creating a new array on heap
- How to stop repeated keyPressed() / keyReleased() events in Swing
- Console application with Java and gradle
- Find top N elements in an Array
- What does the return keyword do in a void method in Java?
- Why does Spring MVC need at least two contexts?
- Ignoring property when deserializing
- Building with Intellij 2017.2 /out directory duplicates files in /build directory
- How to Iterate through HashMap in MyBatis foreach?
- How to create different log files for different packages using same log4j logger?
- Iterate ArrayList in JSP
- Why does SparkSession execute twice for one action?