Returns an immutable copy of the given map whose iteration order has keys sorted by the key
type's natural ordering. No map keys or values may be {@code null}.

@deprecated Prefer {@link com.google.common.collect.ImmutableSortedMap#copyOf(Map)}.
344709
@Deprecated
  public static <K extends Comparable<K>, V> ImmutableMap<K, V> copyWithSortedKeys(
      final Map<K, V> map) {
    return ImmutableSortedMap.copyOf(map);
  }
264783
public static <K, V> SortedMap<K, V> sort(SortedMap<K, V> self) {
        return self;
    }
91622
public static <K, V extends Comparable> Map<K, V> sortByValue(Map<K, V> map, final boolean reverse) {
		return sortByValueInternal(map, reverse ? Ordering.from(new ComparableEntryValueComparator<K, V>()).reverse()
				: new ComparableEntryValueComparator<K, V>());
	}
466146
public static <K, V extends Comparable<? super V>> Map<K, V> sortByValue(
            Map<K, V> map) {
        return sortByValue(map, false);
    }
573060
public static <K, V> MutableList<V> toSortedList(
            Map<K, V> map,
            Comparator<? super V> comparator)
    {
        return Iterate.toSortedList(map.values(), comparator);
    }
127692
@NonNull
  public static <K, V> Map<K, V> immutableCopyOf(@NonNull Map<K, V> map) {
    return Collections.unmodifiableMap(new LinkedHashMap<>(map));
  }
631833
public static Map<String,String> order(Map<String, String> map){
		HashMap<String, String> tempMap = new LinkedHashMap<String, String>();
		List<Map.Entry<String, String>> infoIds = new ArrayList<Map.Entry<String, String>>(	map.entrySet());

		Collections.sort(infoIds, new Comparator<Map.Entry<String, String>>() {
			public int compare(Map.Entry<String, String> o1,Map.Entry<String, String> o2) {
				return (o1.getKey()).toString().compareTo(o2.getKey());
			}
		});

		for (int i = 0; i < infoIds.size(); i++) {
			Map.Entry<String, String> item = infoIds.get(i);
			tempMap.put(item.getKey(), item.getValue());
		}
		return tempMap;
	}
862554
private static String getOrderedMapString(Map<Object, Object> map) {
		ArrayList<String> list = new ArrayList<String>();
		for (Map.Entry<Object, Object> entry : map.entrySet()) {
			if (entry.getValue() != null) {
				Object key = entry.getKey();
				Object value = entry.getValue();
				String objectString = getObjectString(value);
				if (!StringUtils.isEmpty(objectString)) {
					list.add(getObjectString(key) + "=" + objectString + "&");
				}

			}
		}
		int size = list.size();
		String[] arrayToSort = list.toArray(new String[size]);
		Arrays.sort(arrayToSort, String.CASE_INSENSITIVE_ORDER);
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < size; i++) {
			sb.append(arrayToSort[i]);
		}
		return "{" + sb.toString() + "}";
	}
69956
public static <K, V extends Comparable<V>> Stream<Entry<K, V>>
    sortedStreamByValue(Map<K, V> map) {
        return buildEntryStream(map).sorted(comparing(Entry::getValue));
    }
1356409
private static <K, V> Map<K, V> synchronizedCopyMap(Map<K, V> map) {

        if (map == null) {
            return new HashMap<K, V>();
        }

        synchronized (map) {

            return new HashMap<K, V>(map);
        }
    }
1363579
private ImmutableNode mapToNode(final Builder builder, final Map<String, Object> map) {
        for (final Map.Entry<String, Object> entry : map.entrySet()) {
            final String key = entry.getKey();
            final Object value = entry.getValue();
            if (value instanceof List) {
                // For a list, add each list item as a child of this node.
                for (final Object item : (List)value) {
                    addChildNode(builder, key, item);
                }
            } else {
                // Otherwise, add the value as a child of this node.
                addChildNode(builder, key, value);
            }
        }
        return builder.create();
    }
627200
public static <K, V> Map<K, V> of(K key, V value) {
        return new ImmutableMapEntry<K, V>(key, value);
    }
628350
public static <K, V> V getOrDefault(final Map<K, V> map, final Object key, final V defaultValue) {
        if (N.isNullOrEmpty(map)) {
            return defaultValue;
        }

        final V val = map.get(key);

        if (val != null || map.containsKey(key)) {
            return val;
        } else {
            return defaultValue;
        }
    }
928744
public static <K, V> Map<K, V> sortNumberMapByKeyAscending(Map<K, V> map) {
        return sortNumberMapByKeyAscending(map.entrySet());
    }
613898
public static <K1, K2, V> ImmutableSetMultimap<K2, V> copyWithTransformedKeys(
      final SetMultimap<K1,V> setMultimap,
      final Function<? super K1, ? extends K2> function) {
    final ImmutableSetMultimap.Builder<K2,V> ret = ImmutableSetMultimap.builder();
    for (final Map.Entry<K1, V> entry : setMultimap.entries()) {
      // nulls banned by contract
      //noinspection ConstantConditions
      ret.put( function.apply(entry.getKey()), entry.getValue());
    }
    return ret.build();
  }
181837
public static <T> Collection<T> immutableCollectionCopy(Collection<T> collection) {
      if (collection == null) return null;
      if (collection.isEmpty()) return Collections.emptySet();
      if (collection.size() == 1) return Collections.singleton(collection.iterator().next());

      Collection<? extends T> copy = ObjectDuplicator.duplicateCollection(collection);
      if (copy == null)
         copy = attemptCopyConstructor(collection, Collection.class);
      if (copy == null)
         copy = new ArrayList<>(collection);

      return new ImmutableCollectionWrapper<>(copy);
   }
1118209
public static <K, V> Map<K, V> immutableMapWrap(Map<? extends K, ? extends V> map) {
      return new ImmutableMapWrapper<>(map);
   }