Question: I have this list of LinkedHashMap how can order for value?

```
    List<LinkedHashMap<String, Object>> list = more "key:value"......

```

For example on my list i have:

```
    [{"field1": "z", "field2":"a"},
     {"field1" : "b", "field2":"x"}]

```

and i want order based on the values of the "field1" keys for example:

```
    [{"field1": "b", "field2":"x"},
     {"field1" : "z", "field2":"a"}]

```

i have make this class:

```
public class OrderComparator  implements Comparator {
    String field;

    public OrderComparator (String field){
        this.field = field;
    }

    @Override
    public int compare(Object obj1, Object obj2) {
          LinkedHashMap<String, Object> a = (LinkedHashMap<String, Object>) obj1;
          LinkedHashMap<String, Object> b = (LinkedHashMap<String, Object>) obj2;

          return a.get(this.field).toString().compareTo(b.get(this.field).toString());
    }   
}

```

and :

```
Collections.sort(list, new OrderComparator(sortColumn));

```

is correct? thanks to all!!!

Answer: 
Write a [`Comparator<Map<String,Object>>`](http://docs.oracle.com/javase/7/docs/api/java/util/Comparator.html) and use [`Collections.sort(list, comparator)`](http://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#sort%28java.util.List,%20java.util.Comparator%29) to sort your list of maps.

See [Java Tutorial](http://docs.oracle.com/javase/tutorial/) > [Collections Trail](http://docs.oracle.com/javase/tutorial/collections/) > [Object Ordering](http://docs.oracle.com/javase/tutorial/collections/interfaces/order.html)
Use a custom `Comparator`

```
Collections.sort(list, new Comperator<Map<String, Object>>() {
    public int compare(Map<String, Object> a, Map<String, Object> b) {
        return a.get("field1").compareTo(b.get("field1"));
    }
});

```