Returns the keys that maps to the top n max values in the given dict.

    Example:
    --------
    >>> dict_obj = {'a':2, 'b':1, 'c':5}
    >>> get_keys_of_max_n(dict_obj, 2)
    ['a', 'c']
330282
def get_keys_of_max_n(dict_obj, n):
    
    return sorted([
        item[0]
        for item in sorted(
            dict_obj.items(), key=lambda item: item[1], reverse=True
        )[:n]
    ])
233304
public int findHighestKey(int max) {
        int highest = Integer.MIN_VALUE;
        int index = index(hash(max));
        final int maxTry = capacity;
        for (int i = 0; i < maxTry; i++) {
            if (!slotIsFree(index)) {
                int k = keys[index];
                if (k == max) return max;
                if (max > k && k > highest) highest = k;
            }
            index = nextIndex(index);
        }
        return highest;
    }
624875
def top_n(max, metric_method)

      stat_totals = self.values.group_by(&metric_method).map do |metric, stats|
        [metric, stats.reduce(0) { |sum, stat| sum + stat.memsize }, stats.size]
      end

      stats_by_memsize = stat_totals.sort_by! { |metric, memsize, _count| [-memsize, metric] }.take(max).
          map! { |metric, memsize, _count| { data: metric, count: memsize } }
      stats_by_count = stat_totals.sort_by! { |metric, _memsize, count| [-count, metric] }.take(max).
          map! { |metric, _memsize, count| { data: metric, count: count } }

      [stats_by_memsize, stats_by_count]

    end
739632
def reduce_by_keys(orig_dict, keys, default=None):
    
    ret = {}
    for key in keys:
        ret[key] = orig_dict.get(key, default)
    return ret
517931
def _to_dict(self):
        '''  '''
        return dict(minimum=self.minimum._to_dict(),
                    maximum=self.maximum._to_dict())
959449
def dict(self):
        
        from collections import OrderedDict
        SKIP_KEYS = ()
        return OrderedDict(
            (p.key, getattr(self, p.key)) for p in self.__mapper__.attrs if p.key not in SKIP_KEYS)
1152370
def _next_lowest_integer(group_keys):
    
    try: #TODO Replace with max default value when dropping compatibility with Python < 3.4
        largest_int= max([ int(val) for val in group_keys if _is_int(val)])
    except:
        largest_int= 0
    return largest_int + 1
734078
def get_dictkey(In, k, dtype):
    

    Out = []
    for d in In:
        if dtype == '':
            Out.append(d[k])
        if dtype == 'f':
            if d[k] == "":
                Out.append(0)
            elif d[k] == None:
                Out.append(0)
            else:
                Out.append(float(d[k]))
        if dtype == 'int':
            if d[k] == "":
                Out.append(0)
            elif d[k] == None:
                Out.append(0)
            else:
                Out.append(int(d[k]))
    return Out
1002094
def subdict(super_dict, keys):
    
    sub_dict = {}
    valid_keys = super_dict.keys()
    for key in keys:
        if key in valid_keys:
            sub_dict[key] = super_dict[key]

    return sub_dict
1082819
def maximum(attrs, inputs, proto_obj):
    
    if len(inputs) > 1:
        mxnet_op = symbol.maximum(inputs[0], inputs[1])
        for op_input in inputs[2:]:
            mxnet_op = symbol.maximum(mxnet_op, op_input)
    else:
        mxnet_op = symbol.maximum(inputs[0], inputs[0])
    return mxnet_op, attrs, inputs
1035103
def max(self, key=None):
        

        def _max(result, item):
            val = data_get(item, key)

            if result is None or val > result:
                return value

            return result

        return self.reduce(_max)
1360897
def keys(self, key_type=None):
        
        if key_type is not None:
            intermediate_key = str(key_type)
            if intermediate_key in self.__dict__:
                return self.__dict__[intermediate_key].keys()
        else:
            all_keys = {} # in order to preserve keys() type (dict_keys for python3) 
            for keys in self.items_dict.keys():
                all_keys[keys] = None
            return all_keys.keys()
574700
def flattened_nested_key_indices(nested_dict):
    
    outer_keys, inner_keys = collect_nested_keys(nested_dict)
    combined_keys = list(sorted(set(outer_keys + inner_keys)))
    return {k: i for (i, k) in enumerate(combined_keys)}
4237
def str2dict_values(str_in):
    '''
    
    '''
    tmp_dict = str2dict(str_in)
    if tmp_dict is None:
        return None
    return [tmp_dict[key] for key in sorted(k for k in tmp_dict)]
264182
def key_from_dict(**kwargs):
    
    out = []
    stack = [kwargs]
    while stack:
        obj = stack.pop()
        if isinstance(obj, dict):
            stack.extend(sorted(obj.items()))
        elif isinstance(obj, (list, tuple)):
            stack.extend(obj)
        else:
            out.append(str(obj))
    return ''.join(out)
789776
def max(self, property):
        
        self.__prepare()
        try:
            return max(self._json_data, key=lambda x: x[property]).get(property)
        except KeyError:
            raise KeyError("Key is not exists")
787234
def get_dictionary(self):
        

        # output
        k = list()
        d = dict()

        # loop over the root items
        for i in range(self._widget.topLevelItemCount()):

            # grab the parameter item, and start building the name
            x = self._widget.topLevelItem(i).param

            # now start the recursive loop
            self._get_parameter_dictionary('', d, k, x)

        return k, d