KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to sort a simple list of objects by a long - the below isn't working because one of the long strings is pushed to the top simply because it starts with a lower number. So I'm looking for a way to sort these by the actual long values directly The current obj implementation looks something like the below. In the class I'm using this I call Collections.sort(trees); public class Tree implements Comparable<Tree> { public String dist; //value is actually Long public int compareTo(Tree o) { return this.dist.compareTo(o.dist); } }
Tags (comma-separated)
Save Edits
Cancel