Mercurial > dive4elements > river
changeset 6185:7573683925a3
Add sorting for discharge value
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Tue, 04 Jun 2013 16:45:23 +0200 (2013-06-04) |
parents | 58e78e6662fa |
children | a07521dca5b5 |
files | artifacts/src/main/java/org/dive4elements/river/artifacts/states/DischargeState.java |
diffstat | 1 files changed, 11 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/DischargeState.java Tue Jun 04 16:07:33 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/DischargeState.java Tue Jun 04 16:45:23 2013 +0200 @@ -9,6 +9,8 @@ package org.dive4elements.river.artifacts.states; import java.util.List; +import java.util.Collections; +import java.util.Comparator; import org.apache.log4j.Logger; @@ -68,9 +70,15 @@ KVP[] kvp = new KVP[zones.size()]; - for (int i = 0, Z = zones.size(); i < Z; i++) { - DischargeZone zone = zones.get(i); + Collections.sort(zones, new Comparator<DischargeZone>() { + public int compare(DischargeZone a, DischargeZone b) { + return a.getValue().compareTo(b.getValue()); + } + }); + int i = 0; + + for (DischargeZone zone: zones) { String lower = zone.getLowerDischarge(); String upper = zone.getUpperDischarge(); @@ -80,6 +88,7 @@ else { kvp[i] = new KVP(zone.getId(), lower + " - " + upper); } + i++; } return kvp;