Exemplo n.º 1
0
  /**
   * @param d dictionary to sort keys from
   * @return keys from d sorted by ascending value they are mapped to
   */
  public static <T> NSArray<T> keysSortedByValueAscending(final NSDictionary<T, ?> d) {
    NSArray<T> result = null;

    if (d != null && d.count() > 0) {
      final NSArray<T> keys = d.allKeys();
      result =
          ERXArrayUtilities.sortedArrayUsingComparator(keys, new NSDictionaryKeyValueComparator(d));
    }

    return result != null ? result : NSArray.EmptyArray;
  }
Exemplo n.º 2
0
  // if you're keys are not all strings, this method will throw.
  public static NSArray<String> stringKeysSortedAscending(final NSDictionary<String, ?> d) {
    NSArray<String> result = null;

    if (d != null && d.count() > 0) {
      final NSArray<String> keys = d.allKeys();
      result =
          ERXArrayUtilities.sortedArrayUsingComparator(
              keys, NSComparator.AscendingStringComparator);
    }

    return result != null ? result : NSArray.EmptyArray;
  }