Since I\'m just starting with JAVA, I\'m curious what is the best option for implementing sorting in JAVA (for ArrayLists). Below I provide my PHP code.
public i
The way to do this would be to use Collections class, and call Collections.sort(java.util.List, java.util.Comparator)
on your list. It is documented here. The Comparator here is an interface that you would need to implement in order to do a custom sort. To implement the Comparator
interface you need to provide implementations for
int compare(T o1,T o2)
and
boolean equals(Object obj)
.
using the logic you already have in your PHP file.