Skip to content

Instantly share code, notes, and snippets.

@tomotaka
Created June 23, 2014 07:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomotaka/5c4d47c16a9d0980da20 to your computer and use it in GitHub Desktop.
Save tomotaka/5c4d47c16a9d0980da20 to your computer and use it in GitHub Desktop.
schwartz.java
class Tuple {
public Object obj;
public int idx;
Tuple(Object o, int i) { this.obj = o; this.idx = i; }
}
List<Tuple> tmp = new ArrayList<Tuple>();
int i = 0;
for (Object obj : objects) {
tmp.add(new Tuple(obj, i++));
}
Collections.sort(tmp, new Comparator(){
public int compare(Object o1, Object o2) { ... } // compare o1 and o2
public boolean equals(Object o) { ... }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment