Java Map Sort sort(Map src)

Here you can find the source of sort(Map src)

Description

sort

License

Open Source License

Declaration

public static Map<String, Object> sort(Map<String, Object> src) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public class Main {
    public static Map<String, Object> sort(Map<String, Object> src) {
        Map<String, Object> result = new LinkedHashMap<String, Object>();
        List<String> keys = new ArrayList<>(src.keySet());
        Collections.sort(keys);//from w  w w  . j a v  a 2  s  .  co m
        for (String key : keys) {
            result.put(key, src.get(key));
        }
        return result;
    }
}

Related

  1. sort(Map map)
  2. sort(Map map, Comparator> comparator)
  3. sort(Map map)
  4. sort(T map, Comparator> c)
  5. sortBy(Collection collection, final Map valuesMap)
  6. sortByComparator(Map unsortMap)
  7. sortByComparator(Map unsortMap)