Takes a planet and turns it into a key to be sorted by
        :param planet:
        :return:
357578
def _getSortKey(self, planet):
        

        value = eval('planet.'+self._planetProperty)

        # TODO some sort of data validation, either before or using try except

        if self.unit is not None:
            try:
                value = value.rescale(self.unit)
            except AttributeError:  # either nan or unitless
                pass

        return _sortValueIntoGroup(self._allowedKeys[:-1], self._binlimits, value)
886227
def load_planet_list():
    
    planet_list = []
    with open(fldr + os.sep + 'planet_samples.csv') as f:
        hdr = f.readline()
        for line in f:
            #print("Building ", line)
            name, num_seeds, width, height, wind, rain, sun, lava = parse_planet_row(line)
            planet_list.append({'name':name, 'num_seeds':num_seeds, 'width':width, 'height':height, 'wind':wind, 'rain':rain, 'sun':sun, 'lava':lava})
    return planet_list
293716
def pick(source, keys, *, transform=None):
  
  check = keys if callable(keys) else lambda key: key in keys
  return {key: transform(source[key]) if transform else source[key]
          for key in source if check(key)}
632916
def sort_by(self, sf):
    
    params = join_params(self.parameters, {"sf": sf})

    return self.__class__(**params)
253093
def nsorted(
    to_sort: Iterable[str],
    key: Optional[Callable[[str], Any]] = None
) -> List[str]:
    """"""
    if key is None:
        key_callback = _natural_keys
    else:
        def key_callback(text: str) -> List[Any]:
            return _natural_keys(key(text))  # type: ignore

    return sorted(to_sort, key=key_callback)
914217
def sort_dict_by_key(obj):
    
    sort_func = lambda x: x[0]
    return OrderedDict(sorted(obj.items(), key=sort_func))
905952
def sort(key=None, reverse=False, buffersize=None):
    

    return SortComponent(key=key, reverse=reverse, buffersize=buffersize)
233662
def sortable_sortkey_title(instance):
    
    title = sortable_title(instance)
    if safe_callable(title):
        title = title()

    sort_key = instance.getSortKey()
    if sort_key is None:
        sort_key = 999999

    return "{:010.3f}{}".format(sort_key, title)
38897
def cget(self, key):
        
        if key == 'sortable':
            return self._sortable
        elif key == 'drag_cols':
            return self._drag_cols
        elif key == 'drag_rows':
            return self._drag_rows
        else:
            return ttk.Treeview.cget(self, key)
1017512
def _getParLabelAndUnit(self, param):
        

        firstObject = self.objectList[0]

        if isinstance(firstObject, ac.Planet):
            if 'star.' in param:
                return _starPars[param[5:]]  # cut off star. part
            else:
                return _planetPars[param]
        elif isinstance(firstObject, ac.Star):
            return _starPars[param]
        else:
            raise TypeError('Only Planets and Star object are currently supported, you gave {0}'.format(type(firstObject)))
1293151
private function cleanContents($planet)
    {

        CharacterPlanetContent::where('character_id', $this->getCharacterId())
            ->where('planet_id', $planet->planet_id)
            ->whereNotIn(DB::raw('CONCAT(pin_id, ":", type_id)'), $this->planet_contents
                ->map(function ($item) {

                    return $item['pin_id'] . ':' . $item['type_id'];
                })->toArray())
            ->delete();
    }
638839
def natsorted(seq, cmp=natcmp):
    ""
    import copy
    temp = copy.copy(seq)
    natsort(temp, cmp)
    return temp
986169
def _sort(self):
        
        self.versions = OrderedDict(sorted(self.versions.items(), key=lambda v: v[0]))
791987
def re_sort(data):
    
    keys = sorted(data.keys())
    new_data = {}
    for number, key in enumerate(keys):
        new_data[number] = data[key]
    return new_data
255763
def setup_keys(self):
        

        discovery_methods = {}
        discovery_years = {}
        nan_list = []

        # Initial Loop to get keys
        for planet in self.planet_list:
            if 'Solar System' in planet.params['list'] and self.skip_solar_system_planets:
                continue
            try:
                discovery_methods[planet.discoveryMethod] += 1
            except KeyError:
                discovery_methods[planet.discoveryMethod] = 1

            try:
                discovery_years[planet.discoveryYear] += 1
            except KeyError:
                discovery_years[planet.discoveryYear] = 1

            if planet.discoveryMethod is np.nan:
                nan_list.append(planet)

        self.nan_list = nan_list

        return discovery_years
162010
def sort_key(x):
    
    name, (r, u) = x
    return - len(u) + u.count('}') * 100
465793
def _permute(self, ordering: np.ndarray) -> None:
		
		for key in self.keys():
			self[key] = self[key][ordering]