Changes the sort order so that the first course appears after the second course.

@param int|\stdClass $courserecordorid
@param int $moveaftercourseid
@return bool
@throws \moodle_exception
198181
public static function action_course_change_sortorder_after_course($courserecordorid, $moveaftercourseid) {
        $course = \get_course($courserecordorid);
        $category = \core_course_category::get($course->category);
        if (!$category->can_resort_courses()) {
            $url = '/course/management.php?categoryid='.$course->category;
            throw new \moodle_exception('nopermissions', 'error', $url, \get_string('resortcourses', 'moodle'));
        }
        return \course_change_sortorder_after_course($course, $moveaftercourseid);
    }
1048805
public function moveAsNextSiblingOf(NodeInterface $afterNode)
	{
		$pos = $afterNode->getRightValue() + 1;
		$level = $afterNode->getLevel();
		$this->move($pos, $level);

		return $this;
	}
155540
public static function action_course_change_sortorder_down_one(\core_course_list_element $course,
                                                                   \core_course_category $category) {
        if (!$category->can_resort_courses()) {
            throw new \moodle_exception('permissiondenied', 'error', '', null, 'core_course_category::can_resort');
        }
        return \course_change_sortorder_by_one($course, false);
    }
271210
public function process_actions($left, $right, $moveup, $movedown) {
        $category = new stdClass();
        if (!empty($left)) {
            // Moved Left (In to another category).
            $category->id = $left;
            $category->contextid = $this->context->id;
            $event = \core\event\question_category_moved::create_from_question_category_instance($category);
            $event->trigger();
        } else if (!empty($right)) {
            // Moved Right (Out of the current category).
            $category->id = $right;
            $category->contextid = $this->context->id;
            $event = \core\event\question_category_moved::create_from_question_category_instance($category);
            $event->trigger();
        }
        parent::process_actions($left, $right, $moveup, $movedown);
    }
1123848
public static function sortRecord($records, $field, $order=true)
    {
        $new_array = array();
        $sortable_array = array();

        if (count($records) > 0) {
            foreach ($records as $k => $v) {
                if (is_array($v)) {
                    foreach ($v as $k2 => $v2) {
                        if ($k2 == $field) {
                            $sortable_array[$k] = $v2;
                        }
                    }
                } else {
                    $sortable_array[$k] = $v;
                }
            }

            switch ($order) {
                case true:
                    asort($sortable_array);
                break;
                case false:
                    arsort($sortable_array);
                break;
            }

            foreach ($sortable_array as $k => $v) {
                $new_array[$k] = $records[$k];
            }
        }

        return $new_array;
    }
1328059
public static function moveToBefore($moveNavId, $toBeforeNavId)
    {
        $move = self::findOne($moveNavId);
        $to = self::findOne($toBeforeNavId);

        if (!$move || !$to) {
            return false;
        }
        
        $response = self::checkDuplicateAlias($move->id, $to->parent_nav_id);
        
        if ($response !== true) {
            return $response;
        }

        $to->moveUpstairs();

        $move->nav_container_id = $to->nav_container_id;
        $move->parent_nav_id = $to->parent_nav_id;
        $move->sort_index = $to->sort_index;
        $move->update();

        foreach ($move->getRecursiveChildren() as $child) {
            $child->updateAttributes(['nav_container_id' => $to->nav_container_id]);
        }
        
        return true;
    }
876587
public function process_actions($left, $right, $moveup, $movedown) {
        //should this action be processed by this list object?
        if (!(array_key_exists($left, $this->records) || array_key_exists($right, $this->records) || array_key_exists($moveup, $this->records) || array_key_exists($movedown, $this->records))) {
            return false;
        }
        if (!empty($left)) {
            $oldparentitem = $this->move_item_left($left);
            if ($this->item_is_last_on_page($oldparentitem->id)) {
                // Item has jumped onto the next page, change page when we redirect.
                $this->page ++;
                $this->pageurl->params(array($this->pageparamname => $this->page));
            }
        } else if (!empty($right)) {
            $this->move_item_right($right);
            if ($this->item_is_first_on_page($right)) {
                // Item has jumped onto the previous page, change page when we redirect.
                $this->page --;
                $this->pageurl->params(array($this->pageparamname => $this->page));
            }
        } else if (!empty($moveup)) {
            $this->move_item_up_down('up', $moveup);
            if ($this->item_is_first_on_page($moveup)) {
                // Item has jumped onto the previous page, change page when we redirect.
                $this->page --;
                $this->pageurl->params(array($this->pageparamname => $this->page));
            }
        } else if (!empty($movedown)) {
            $this->move_item_up_down('down', $movedown);
            if ($this->item_is_last_on_page($movedown)) {
                // Item has jumped onto the next page, change page when we redirect.
                $this->page ++;
                $this->pageurl->params(array($this->pageparamname => $this->page));
            }
        } else {
            return false;
        }

        redirect($this->pageurl);
    }
1113614
public static function move_category(category_controller $category, int $beforeid = 0) {
        global $DB;
        $records = $DB->get_records(category::TABLE, [
            'component' => $category->get('component'),
            'area' => $category->get('area'),
            'itemid' => $category->get('itemid')
        ], 'sortorder, id', '*');

        $id = $category->get('id');
        $categoriesids = array_values(array_diff(array_keys($records), [$id]));
        $idx = $beforeid ? array_search($beforeid, $categoriesids) : false;
        if ($idx === false) {
            // Set as the last category.
            $categoriesids = array_merge($categoriesids, [$id]);
        } else {
            // Set before category with id $beforeid.
            $categoriesids = array_merge(array_slice($categoriesids, 0, $idx), [$id], array_slice($categoriesids, $idx));
        }

        foreach (array_values($categoriesids) as $idx => $categoryid) {
            // Use persistent class to update the sortorder for each category that needs updating.
            if ($records[$categoryid]->sortorder != $idx) {
                $c = ($categoryid == $id) ? $category : category_controller::create(0, $records[$categoryid]);
                $c->set('sortorder', $idx);
                $c->save();
            }
        }
    }
1000439
public static function action_course_change_sortorder_down_one_by_record($courserecordorid) {
        if (is_int($courserecordorid)) {
            $courserecordorid = get_course($courserecordorid);
        }
        $course = new \core_course_list_element($courserecordorid);
        $category = \core_course_category::get($course->category);
        return self::action_course_change_sortorder_down_one($course, $category);
    }
75498
public FieldList moveThruMultipleTables(int iRelPosition) throws DBException
    { // ****ONLY TESTED FOR iRelPosition = +1****
        boolean bIsOpen = m_bIsOpen;
        if (!m_bIsOpen)
            this.open();
        BaseTable table = null;
        BaseTable tableNext = null;
        if (((m_iRecordStatus & DBConstants.RECORD_NEXT_PENDING) == DBConstants.RECORD_NEXT_PENDING)
            && (iRelPosition == DBConstants.NEXT_RECORD))
        {
            m_iRecordStatus = DBConstants.RECORD_NORMAL;
            tableNext = this.getCurrentTable();   // Special case - last call was hasNext()
        }
        else if (((m_iRecordStatus & DBConstants.RECORD_PREVIOUS_PENDING) == DBConstants.RECORD_PREVIOUS_PENDING)
            && (iRelPosition == DBConstants.PREVIOUS_RECORD))
        {
            m_iRecordStatus = DBConstants.RECORD_NORMAL;
            tableNext = this.getCurrentTable();   // Special case - last call was hasNext()
        }
        else
        { // First, make sure all the tables are opened and positioned on valid records.
            if ((!bIsOpen) || (iRelPosition == DBConstants.FIRST_RECORD))   // Need to use a different variable
            {   // If this is the first time thru, open and move to the first record
                Iterator<BaseTable> iterator = this.getTables();
                while (iterator.hasNext())
                {
                    table = iterator.next();
                    table.close();
                    table.getRecord().setKeyArea(this.getRecord().getDefaultOrder());
                    if (table.hasNext())
                    {
                        if (table != this.getCurrentTable())
                            table.move(+1);   // Move to first record
                        else
                            iRelPosition = +1;
                    }
                }
                m_bIsOpen = true; // Yes this file is now open.
            }
            if (!this.getCurrentTable().isEOF())
                this.getCurrentTable().move(iRelPosition);  // First, move the current table in the correct direction.
        // Now, compare the records to find the lowest key
            Iterator<BaseTable> iterator = this.getTables();
            while (iterator.hasNext())
            {
                table = iterator.next();
                if (!table.isEOF())
                {
                    if (tableNext == null)
                        tableNext = table;      // None here yet, this is the lowest
                    else
                    { // Now compare and get the lowest
                        int iCompareValue = 0;
                        int iKeyFields = table.getRecord().getKeyArea().getKeyFields() + DBConstants.MAIN_KEY_FIELD;
                        for (int iKeyFieldSeq = DBConstants.MAIN_KEY_FIELD; iKeyFieldSeq < iKeyFields; iKeyFieldSeq++)
                        {
                            BaseField fldCompare = table.getRecord().getKeyArea().getKeyField(iKeyFieldSeq).getField(DBConstants.FILE_KEY_AREA);
                            BaseField fldNext = tableNext.getRecord().getKeyArea().getKeyField(iKeyFieldSeq).getField(DBConstants.FILE_KEY_AREA);
                            iCompareValue = fldCompare.compareTo(fldNext);
                            if (this.getRecord().getKeyArea() != null)
                                if (this.getRecord().getKeyArea().getKeyField(iKeyFieldSeq) != null)
                                    if (this.getRecord().getKeyArea().getKeyOrder(iKeyFieldSeq) == DBConstants.DESCENDING)
                                iCompareValue = -iCompareValue;
                            if (iCompareValue != 0)
                                break;
                        }
                        if (iCompareValue < 0)
                            tableNext = table;      // This is the lowest so far.
                    }
                }
            }
        }
        if (tableNext == null)
        {
            Iterator<BaseTable> iterator = this.getTables();
            while (iterator.hasNext())
            {   // If this table is suppose to be PAST EOF, make sure all the records are too.
                table = iterator.next();
                if (iRelPosition == DBConstants.NEXT_RECORD)
                    if (table.isEOF())
                        table.move(+1);
            }
            return null;
        }
        this.setCurrentTable(tableNext);    // Never allow currentTable to be null.
        Record record = tableNext.getRecord();
        for (int iFieldSeq = DBConstants.MAIN_FIELD; iFieldSeq < record.getFieldCount(); ++iFieldSeq)
        {
//?         if (bDisplayOption)
            record.getField(iFieldSeq).displayField();      // Display this field
        }
        return record;
    }
275080
public void moveToRecordId(RecordId rid) {
		moveTo(rid.block().number());
		rp.moveToId(rid.id());
	}
316148
public function moveEventAlbum($albumId, $parentAlbumId = null)
    {
        if (is_null($albumId) || $albumId == '') {
            throw new Exception('The albumId is required to move an album.');
        }

        $params = array(
            'method' => 'sp.album.move',
            'album_id' => $albumId,
            'parent_id' => $parentAlbumId
        );

        return $this->_makeApiRequest($params);
    }
1266207
protected function _operationAfter($action, \Cms\Orm\CmsFileRecord $record)
    {
        return \Mmi\Mvc\ActionHelper::getInstance()->action(new \Mmi\Http\Request(array_merge($record->toArray(), $action)));
    }
363470
@Override
    public Record nextRecord() {
        Record next = sequenceRecordReader.nextRecord();
        next.setRecord(transformProcess.execute(next.getRecord()));
        return next;
    }
282483
public function moveBlockToDisplayOrderPosition($afterBlock)
    {
        // first, we increase the display order of all blocks found after this one.
        $db = Loader::db();
        $c = $this->getBlockCollectionObject();
        if ($afterBlock instanceof self) {
            $block = self::getByID(
                $afterBlock->getBlockID(),
                $this->getBlockCollectionObject(),
                $this->getBlockAreaObject()
                );
            $q = 'update CollectionVersionBlocks set cbDisplayOrder = cbDisplayOrder + 1 where cID = ? and (cvID = ? or cbIncludeAll=1) and arHandle = ? and cbDisplayOrder > ?';
            $v = [$c->getCollectionID(), $c->getVersionID(), $this->getAreaHandle(), $block->getBlockDisplayOrder()];
            $db->Execute($q, $v);

            // now we set this block's display order to 1 + the current block
            $q = 'update CollectionVersionBlocks set cbDisplayOrder = ? where bID = ? and cID = ? and (cvID = ? or cbIncludeAll=1) and arHandle = ?';
            $v = [
                $block->getBlockDisplayOrder() + 1,
                $this->getBlockID(),
                $c->getCollectionID(),
                $c->getVersionID(),
                $this->getAreaHandle(),
            ];
            $db->Execute($q, $v);
        } else {
            $q = 'update CollectionVersionBlocks set cbDisplayOrder = cbDisplayOrder + 1 where cID = ? and (cvID = ? or cbIncludeAll=1) and arHandle = ?';
            $v = [$c->getCollectionID(), $c->getVersionID(), $this->getAreaHandle()];
            $db->Execute($q, $v);

            $q = 'update CollectionVersionBlocks set cbDisplayOrder = ? where bID = ? and cID = ? and (cvID = ? or cbIncludeAll=1) and arHandle = ?';
            $v = [0, $this->getBlockID(), $c->getCollectionID(), $c->getVersionID(), $this->getAreaHandle()];
            $db->Execute($q, $v);
        }
    }
955663
public function onLocalRecordsFirstRecord(Record $record, $records, $position, BaseRecords $baseRecords)
    {
        if (!$this->checkRecordPlugin($baseRecords)) {
            return;
        }

        $this->updater->setLocalRecord($record->getPlayer()->getNickname(), $record->getCheckpoints());
    }
1150500
public static function move_category(int $id, int $beforeid) {
        $params = self::validate_parameters(self::move_category_parameters(),
            ['id' => $id, 'beforeid' => $beforeid]);
        $category = core_customfield\category_controller::create($id);
        $handler = $category->get_handler();
        self::validate_context($handler->get_configuration_context());
        if (!$handler->can_configure()) {
            throw new moodle_exception('nopermissionconfigure', 'core_customfield');
        }
        $handler->move_category($category, $params['beforeid']);
    }