Initial commit
This commit is contained in:
commit
bfbe536886
59 files changed
+2540
No files matched your search
@@ -0,0 +1,26 @@
|
||||
package org.scribe.utils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class MapUtils
|
||||
{
|
||||
|
||||
public static final Map<String, String> sort(Map<String, String> map)
|
||||
{
|
||||
Preconditions.checkNotNull(map, "Cannot sort a null object.");
|
||||
|
||||
Map<String, String> sorted = new LinkedHashMap<String, String>();
|
||||
for (String key : getSortedKeys(map))
|
||||
{
|
||||
sorted.put(key, map.get(key));
|
||||
}
|
||||
return sorted;
|
||||
}
|
||||
|
||||
private static List<String> getSortedKeys(Map<String, String> map)
|
||||
{
|
||||
List<String> keys = new ArrayList<String>(map.keySet());
|
||||
Collections.sort(keys);
|
||||
return keys;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user