2
나는 lambdaj을 좋아하고 그것을 많이 사용하지만 여러 정렬 조건을 사용하여 목록을 정렬 할 수 있는지는 알 수 없습니다.lambdaj와 Java의 다중 정렬 조건
다음은 Google Collections을 사용한 예입니다. lambdaj에서 같은 일을 할 수 있습니까?
결과 순위는 첫째 색상별로 다음 이름으로 공식 Lambdaj 페이지에 제공되지 않는 일을
Function<Fruit, Color> getColorFunction = new Function<Fruit, Color>() {
public Color apply(Fruit from) {
return from.getColor();
}
};
Function<Fruit, String> getNameFunction = new Function<Fruit, String>() {
public String apply(Fruit from) {
return from.getName();
}
};
Ordering<Fruit> colorOrdering = Ordering.natural().onResultOf(getColorFunction);
Ordering<Fruit> nameOrdering = Ordering.natural().onResultOf(getNameFunction);
Ordering<Fruit> colorAndNameOrdering = colorOrdering.compound(nameOrdering);
ImmutableSortedSet<Fruit> sortedFruits = ImmutableSortedSet.orderedBy(
colorAndNameOrdering).addAll(fruits).build();
[LambdaCollections] (http://code.google.com/p/lambdaj/wiki/LambdaCollections)가 그렇게해야하나요? – MadChuckle