Get a list of possible counter moves, sorted by best option
422638
function getPlayerCounters(player, attacker, game) {
  return player.hand
    .map((card) => {
      return card.validCounters ? card.validCounters(player, attacker, game) : []
    })
    .reduce((acc, array) => {
      return acc.concat(array)
    }, [])
    .sort((counterA, counterB) => counterB.weight - counterA.weight)
}
227997
def as_sorted_list(options):
        
        if len(options) > 0:
            options = sorted(options, key=lambda o: o.number)
        return options
1052947
def sorted(self):
        """"""
        for i in range(0, self.tabs.tabBar().count() - 1):
            if (self.tabs.tabBar().tabText(i) >
                    self.tabs.tabBar().tabText(i + 1)):
                return False
        return True
739335
def has_free_moves(self):
        """"""
        return any(self._can_cell_be_merged(x, y)
                   for x in range(self.COUNT_X)
                   for y in range(self.COUNT_Y))
1224983
def info(self):
        ''' 
        '''
        return sorted(self._checkers.values(), key=lambda x: (x.ns, x.name))
14836
def get_moves():
    """"""
    page = requests.get('http://bulbapedia.bulbagarden.net/wiki/List_of_moves')
    soup = bs4.BeautifulSoup(page.text)
    table = soup.table.table
    tablerows = [tr for tr in table.children if tr != '\n'][1:]

    moves = {}

    for tr in tablerows:
        cells = tr.find_all('td')
        move_name = cells[1].get_text().strip(' \n*').replace(' ', '-').lower()
        move_id = int(cells[0].get_text().strip())
        move_type = cells[2].get_text().strip()
        move_ps = cells[3].get_text().strip()
        moves[move_name] = {'id':move_id, 'type':move_type, 'ps':move_ps}

    srcpath = path.dirname(__file__)
    with io.open(path.join(srcpath, 'moves.json'), 'w', encoding='utf-8') as f:
        f.write(json.dumps(moves, ensure_ascii=False))
1079086
def _sort_io_counters(process,
                      sortedby='io_counters',
                      sortedby_secondary='memory_percent'):
    """"""
    return process[sortedby][0] - process[sortedby][2] + process[sortedby][1] - process[sortedby][3]
849770
def counters!
      the_counters = { processing: 0 }

      names = @lifecycle.states.keys
      results = RedisRds::Object.connection.multi do
        self.class::STATES_TERMINAL.each { |name| get_list(name).size }
        names.each { |name| get_list(name).size }
        @processing.getall
      end

      (self.class::STATES_TERMINAL + names).each do |name|
        the_counters[name] = results.shift.to_i
      end

      the_counters[:processing] = results.shift.reduce(0) { |sum, pair| sum + pair.last.to_i }

      return the_counters
    end
807091
def get_ordered_ifo_list(ifocomb, ifo_ids):
    
    # combination_prec stores precedence info for the detectors in the combination
    combination_prec = {ifo: ifo_ids[ifo] for ifo in ifocomb}
    ordered_ifo_list = sorted(combination_prec, key = combination_prec.get)
    pivot_ifo = ordered_ifo_list[0]
    fixed_ifo = ordered_ifo_list[1]

    return pivot_ifo, fixed_ifo, ''.join(ordered_ifo_list)
1226352
function FindExceptionInList(playerCards, dealerCard, overrides)
{
    // First create a sorted version of this list    
    var sortedHand = playerCards.slice(0).sort((a, b) => (a-b));
    var action = null;

    // Now you can compare
    for (var i = 0; i < overrides.length; i++)
    {
        if ((dealerCard == overrides[i].dealer) && (sortedHand.length == overrides[i].hand.length))
        {
            for (var card = 0; card < sortedHand.length; card++)
            {
                if (sortedHand[card] != overrides[i].hand[card])
                {
                    // Not a match
                    break;
                }
            }

            // If we got all the way through, it's a match!
            if (card == sortedHand.length)
            {
                // We did it!
                action = overrides[i].action;
                break;
            }
        }
    }

    return action;
 }
1099006
def find_all(self, board: Union[chess.Board, int], *, minimum_weight: int = 1, exclude_moves: Container[chess.Move] = ()) -> Iterator[Entry]:
        """"""
        try:
            key = int(board)  # type: ignore
            context = None  # type: Optional[chess.Board]
        except (TypeError, ValueError):
            context = typing.cast(chess.Board, board)
            key = zobrist_hash(context)

        i = self.bisect_key_left(key)
        size = len(self)

        while i < size:
            entry = self[i]
            i += 1

            if entry.key != key:
                break

            if entry.weight < minimum_weight:
                continue

            if context:
                move = context._from_chess960(context.chess960, entry.move.from_square, entry.move.to_square, entry.move.promotion, entry.move.drop)
                entry = Entry(entry.key, entry.raw_move, entry.weight, entry.learn, move)

            if exclude_moves and entry.move in exclude_moves:
                continue

            if context and not context.is_legal(entry.move):
                continue

            yield entry
1365748
def counter(items):
    
    results = {}
    for item in items:
        results[item] = results.get(item, 0) + 1
    return results
1221975
def bleakest_moves(self, start_game, end_game):
        
        bleak = b'bleakest_q'
        rows = self.bt_table.read_rows(
            ROW_PREFIX.format(start_game),
            ROW_PREFIX.format(end_game),
            filter_=bigtable_row_filters.ColumnRangeFilter(
                METADATA, bleak, bleak))

        def parse(r):
            rk = str(r.row_key, 'utf-8')
            g, m = _game_row_key.match(rk).groups()
            q = r.cell_value(METADATA, bleak)
            return int(g), int(m), float(q)
        return sorted([parse(r) for r in rows], key=operator.itemgetter(2))
1195642
def _get_sorted_action_keys(self, keys_list):
        
        # The names can be found in reflexrulewidget.pt inside the
        # Reflex action rules list section.
        action_list = []
        for key in keys_list:
            if key.startswith('action-'):
                action_list.append(key)
        action_list.sort()
        return action_list
277882
def get_ordered_options(self, hidden=False):
        
        return [opt.as_dict() for opt in self.options.values() \
                                            if hidden or (not opt.hidden)]
195150
function() {

            // return list
            var ret = [];

            // get current timestamp
            var timestamp = this.getTimestamp();

            // iterate over storage keys to find all counters
            var that = this;
            this._iterKeys(function(storageKey) {

                // if its not a timestamp key, skip it
                if (storageKey.indexOf(that._expiration_key_prefix) === 0) {

                    // get item key
                    var itemKey = storageKey.substr(that._expiration_key_prefix.length);

                    // if expired remove it + the item
                    if (that.isExpired(itemKey)) {

                        that.removeItem(itemKey);
                        ret.push(itemKey);
                    }
                }
            });

            // return list with removed keys
            return ret;
        }
1063683
def sorted_key_list(self):
        """"""
        if not self.is_baked:
            self.bake()
        key_value_tuple = sorted(self.dct.items(),
                                 key=lambda x: x[1]['__abs_time__'])
        skl = [k[0] for k in key_value_tuple]
        return skl