• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/item/task/collection/checklist.php
  • Класс: BitrixTasksItemTaskCollectionCheckList
  • Вызов: CheckList::sealSortIndex
public function sealSortIndex()
{
	if($this->count())
	{
		$sortCol = static::getSortColumnName();

		$hasSort = false;
		/**
		 * @var Item $v
		 */
		foreach($this->values as $k => $v)
		{
			if($v->containsKey($sortCol))
			{
				$hasSort = true;
				break;
			}
		}

		if($hasSort)
		{
			// some of items contain SORT column, so we have to sort by it first
			// otherwise we will leave the origin order
			$this->sort(array($sortCol => 'asc'));
		}

		$sort = 0;
		foreach($this->values as $k => $v)
		{
			$v[$sortCol] = $sort++;
		}
	}
}