.. highlightlang:: us .. index:: sorti .. _sorti: sorti ===== .. us.tag sorti ENGLISH STR Changed500 Changed5502 :ref:`sorti` sorts a real, complex or string matrix or vector in ascending order and returns an index vector of the sorted matrix. .. function:: rvSortIndex = sorti(mUnsorted) rvSortIndex = sorti(mUnsorted, options) .. us.return **Return Value** *rvSortIndex* is a index vector of the sorted matrix. .. us.params **Parameters** .. uparam:: mUnsorted *mUnsorted* is the unsorted matrix. The first column will be sorted. .. uparam:: options *options* is a OR combination of the following values: .. list-table:: :header-rows: 0 * - SORT_REVERT (1) - Sort in descending order. Default ascending order. * - SORT_CASE (2) - Case sensitive sorting (only for string vectors/matrices). Default: :ref:`sorti` ignores case. .. us.example **Example** :: * srand("test") 1.0000 * a = rand(3,3) * a 0.5536 0.7214 0.6267 0.0735 0.9892 0.8892 0.4024 0.0891 0.5894 * sorti(a) // sort first column 2.0000 3.0000 1.0000 * // sort second column * sorti(a[;2]) 3.0000 1.0000 2.0000 * // sort third column * a = a[sorti(a[;3]);] * a 0.4024 0.0891 0.5894 0.5536 0.7214 0.6267 0.0735 0.9892 0.8892 .. us.history **History** .. list-table:: :header-rows: 1 * - Version - Description * - R2013.2 - Uses mergesort instead of quicksort. Mergesort is a stable sort, which means the implementation preserves the input order of equal elements in the sorted output. * - 5.0.0 - New parameter *options*. .. seealso:: :ref:`sort`, :ref:`reshape` :sub:`id-1715870`