public static void columnSelected(JTable table, int columnIndex) {
		SortedTableModel sortedModel = getSortedTableModel(table);
		if (sortedModel == null) {
			return;
		}

		int modelColumnIndex = getColumnModelIndex(table, columnIndex);
		if (modelColumnIndex < 0) {
			return;
		}

		if (!sortedModel.isSortable(modelColumnIndex)) {
			return;
		}

		TableSortState columnSortStates = sortedModel.getTableSortState();

		TableSortStateEditor editor = new TableSortStateEditor(columnSortStates);
		if (editor.isColumnSorted(modelColumnIndex)) {
			editor.flipColumnSortDirection(modelColumnIndex);
		}
		else {
			editor.clear();
			editor.addSortedColumn(modelColumnIndex);
		}

		TableSortState newSortState = editor.createTableSortState();
		sortedModel.setTableSortState(newSortState);

		if (sortEmphasizingAnimationRunner != null) {
			sortEmphasizingAnimationRunner.stop();
		}

		int n = newSortState.getSortedColumnCount();
		if (n >= 2) { // don't emphasize a single column
			sortEmphasizingAnimationRunner =
				new SortEmphasisAnimationRunner(table, newSortState, columnIndex);
			sortEmphasizingAnimationRunner.start();
		}

		repaintTableHeaderForSortChange(table);
	}
Attempts to sort the given table based upon the given column index.  If the {@link TableModel}
of the given table is not a {@link SortedTableModel}, then this method will do nothing.
<p>
If the given column index is not sortable, then this method will not change the state of
the model.  Otherwise, the sorted model will be sorted on the given column index.  The
results of calling this method depend upon the current sorted state of the given column:
<ol>
<li>if the column is not yet the sorted column, then the column is made the sorted
column, if sortable, <b>and any other sorted columns will be made unsorted</b>, or</li>
<li>if the column is the sorted column and the direction will simply be toggled.</li>
</ol>

@param table The table whose model shall be sorted.
@param columnIndex The column index upon which to sort.
Ghidra/Framework/Docking/src/main/java/docking/widgets/table/TableUtils.java