cycle_sorting computes and sets new sort criteria based on the current criteria. If the given column id already exists in the sort criteria, the column's sort direction is updated by calling
next_dir on its current sort direction. Otherwise, the sort direction is computed by calling
None. If the new direction is
None, the column id is removed from the sort criteria.
keep_existing_cols is passed in as an argument, all existing column ids are kept in the sort criteria, and the given column id is added or promoted to the front of the sort criteria list (i.e. given the highest precedence).
keep_existing_cols is not passed in, all column ids apart from the given one are removed from the sort criteria.