# ISSortPermutation
calculate the permutation of the indices into a nondecreasing order. 
## Synopsis
```
#include "petscis.h"  
PetscErrorCode ISSortPermutation(IS f, PetscBool always, IS *h)
```
Not collective.


## Input Parameters

- ***f      -*** `IS` to sort
- ***always -*** build the permutation even when f's indices are nondecreasing.



## Output Parameter

- ***h    -*** permutation or NULL, if f is nondecreasing and always == `PETSC_FALSE`.





## Notes
Indices in f are unchanged. f[h[i]] is the i-th smallest f index.

If always == `PETSC_FALSE`, an extra check is performed to see whether
the f indices are nondecreasing. h is built on `PETSC_COMM_SELF`, since
the permutation has a local meaning only.


## See Also
 `IS`, `ISLocalToGlobalMapping`, `ISSort()`

## Level
advanced

## Location
<A HREF="PETSC_DOC_OUT_ROOT_PLACEHOLDER/src/vec/is/is/utils/isdiff.c.html#ISSortPermutation">src/vec/is/is/utils/isdiff.c</A>


---
[Edit on GitLab](https://gitlab.com/petsc/petsc/-/edit/release/src/vec/is/is/utils/isdiff.c)


[Index of all IS routines](index.md)  
[Table of Contents for all manual pages](/docs/manualpages/index.md)  
[Index of all manual pages](/docs/manualpages/singleindex.md)  
