gsort ===== sorting by quick sort agorithm Calling Sequence ~~~~~~~~~~~~~~~~ :: [B [,k]]=gsort(A) [B [,k]]=gsort(A,option) [B [,k]]=gsort(A,option,direction) Arguments ~~~~~~~~~ :A a real,an integer or a character string vector/matrix or a sparse vector. : :option a character string. It gives the type of sort to perform: + 'r' : each column of `A` is sorted + 'c': each row of `A` is sorted + 'g': all elements of `A` are sorted. It is the default value. + 'lr': lexicographic sort of the rows of `A` + 'lc': lexicographic sort of the columns of `A` : :direction a character string. It gives the ordering direction: `'i'` stand for increasing and `'d'` for decreasing order (default). : :B an array with same type and dimensions as `A`. : :k a real array with integer values and same dimensions as `A`. Contains the origin indices. : Description ~~~~~~~~~~~ `gsort` implements a "quick sort" algorithm for various data types. + `B=gsort(A,'g')`, `B=gsort(A,'g','d')` and `B=gsort(A)` sort the elements of the array `A`, seen as `A(:)` in a decreasing order. `B=gsort(A,'g','i')` sort the elements of the array `A` in the increasing order. + `B=gsort(A,'lr')` sorts the rows of `A` in lexical decreasing order. `B` is obtained by a permutation of the rows of matrix `A` in such a way that the rows of `B` verify `B(i,:)>=B(j,:)` if `i=B(:,j)` if `i