Created
June 23, 2014 07:18
-
-
Save tomotaka/5c4d47c16a9d0980da20 to your computer and use it in GitHub Desktop.
schwartz.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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