Force a reorder of the displayed items
355304
def reorder(self, single_column=False):
        """"""
        if single_column:
            columns = self.sortOrder[:1]
        else:
            columns = self.sortOrder
        for ascending,column in columns[::-1]:
            # Python 2.2+ guarantees stable sort, so sort by each column in reverse 
            # order will order by the assigned columns 
            self.sorted.sort( key=column.get, reverse=(not ascending))
264554
def move_up(self):
        """"""
        if self.current_item.parent is not None:
            self.current_item = self.current_item.parent

        for f in self._hooks["up"]:
            f(self)
        if self.current_item is self.root:
            for f in self._hooks["top"]:
                f(self)
        return self
978517
def addfirst(self, item, new_priority=None):
        """"""

        with self.lock:

            self_data = self.data

            try:
                priority = self_data[0][1]
                if new_priority is not None:
                    if new_priority < priority:
                        raise ValueError('Priority must be >= '
                                         'highest priority.')
                    else:
                        priority = new_priority
            except IndexError:
                priority = 0 if new_priority is None else new_priority

            self_data.appendleft((item, priority))
            self_items = self.items
            maxlen = self._maxlen

            try:
                self_items[item] += 1
            except TypeError:
                self_items[repr(item)] += 1

            if maxlen is not None and maxlen < len(self_data):
                self._poplast()
747000
def user_fields_reorder(self, data, **kwargs):
        ""
        api_path = "/api/v2/user_fields/reorder.json"
        return self.call(api_path, method="PUT", data=data, **kwargs)
27662
function(ref, item) {
          var priority = item['.priority'];
          delete item['.priority'];
          ref.setWithPriority(item, priority);
          return item;
        }
1203798
def _move_to_top(self, pos):
        """"""
        if pos > 0:
            self.queue.rotate(-pos)
            item = self.queue.popleft()
            self.queue.rotate(pos)
            self.queue.appendleft(item)
1244069
def reorder_keys(self, keys):
        ''''''
        if len(keys) != len(self._set):
            raise ValueError('The supplied number of keys does not match.')
        if set(keys) != self._set:
            raise ValueError('The supplied keys do not match the current set of keys.')
        self._keys = list(keys)
144939
protected function rescanDisplayOrder()
    {
        $displayOrder = 0;
        $btsID = $this->getBlockTypeSetID();
        $app = Application::getFacadeApplication();
        $db = $app->make(Connection::class);
        $rs = $db->executeQuery('select btID from BlockTypeSetBlockTypes where btsID = ? order by displayOrder asc', [$btsID]);
        while (($btID = $rs->fetchColumn()) !== false) {
            $db->update(
                'BlockTypeSetBlockTypes',
                [
                    'displayOrder' => $displayOrder,
                ],
                [
                    'btID' => $btID,
                    'btsID' => $btsID,
                ]
            );
            ++$displayOrder;
        }
    }
995723
def reload(self):
        
        enum = self._enum
        if not enum:
            return
        
        self.clear()
        
        if not self.isRequired():
            self.addItem('')
        
        if self.sortByKey():
            self.addItems(sorted(enum.keys()))
        else:
            items = enum.items()
            items.sort(key = lambda x: x[1])
            
            self.addItems(map(lambda x: x[0], items))
54470
def shift_ordering_up(cls, parent_id, position, db_session=None, *args, **kwargs):
        
        db_session = get_db_session(db_session)
        query = db_session.query(cls.model)
        query = query.filter(cls.model.parent_id == parent_id)
        query = query.filter(cls.model.ordering >= position)
        query.update(
            {cls.model.ordering: cls.model.ordering + 1}, synchronize_session=False
        )
        db_session.flush()
787168
def nice_display(item):
    """"""
    if hasattr(item, 'all'):  # RelatedManager: display a list
        return ', '.join(map(text_type, item.all()))
    return item
833823
public function force_regrading() {
        global $DB;
        $this->needsupdate = 1;
        //mark this item and course item only - categories and calculated items are always regraded
        $wheresql = "(itemtype='course' OR id=?) AND courseid=?";
        $params   = array($this->id, $this->courseid);
        $DB->set_field_select('grade_items', 'needsupdate', 1, $wheresql, $params);
    }
160791
public function previous()
    {
        $this->_itemValid = true;

        if (!prev($this->_items)) {
            $this->_itemValid = false;
        } else {
            $this->_itemPosition--;
        }
    }
832472
function adjust(fn, thisObj) {
				var nq = fn.call(thisObj, q);
				if (!Array.isArray(nq)) throw new Error("reorder function does not return array");
				q = nq;
			}
188955
def OnItemSelected(self, event):
        """"""

        value = event.m_itemIndex
        self.startIndex = value

        self.switching = True
        post_command_event(self, self.GridActionTableSwitchMsg, newtable=value)
        self.switching = False

        event.Skip()
69488
def _choose_what_to_display(self, force_refresh=False):
        
        for _ in range(len(self.available_combinations)):
            if (
                self.displayed is None
                and self.available_combinations[0] == self.active_layout
            ):
                self.displayed = self.available_combinations[0]
                break
            else:
                if self.displayed == self.available_combinations[0]:
                    break
                else:
                    self.available_combinations.rotate(1)
        else:
            if force_refresh:
                self.displayed = self.available_combinations[0]
            else:
                self.py3.log('xrandr error="displayed combination is not available"')
79754
def re_enqueue(self, item):
        """"""
        if 'retries' in item:
            retries = item['retries']
            if retries >= self.MAX_RETRIES:
                log.warn("Failed to execute {} after {} retries, give it "
                         " up.".format(item['method'], retries))
            else:
                retries += 1
                item['retries'] = retries
                self._q.put_nowait(item)
        else:
            item['retries'] = 1
            self._q.put_nowait(item)