# Is there a function behaving the same as next\_permutation does in C++?

**URL:** https://discourse.julialang.org/t/is-there-a-function-behaving-the-same-as-next-permutation-does-in-c/63451
**Category:** General Usage
**Tags:** question
**Created:** [June 23, 2021, 3:39pm UTC](https://discourse.julialang.org/t/is-there-a-function-behaving-the-same-as-next-permutation-does-in-c/63451 "2021-06-23T15:39:46Z")
**Posts on this page:** 1
**Showing post:** 7

<div class="post-metadata">

### Author: ![AquaIndigo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aquaindigo/32/15820_2.png) [@AquaIndigo](https://discourse.julialang.org/u/AquaIndigo)
#### Post date: [June 24, 2021, 3:04am UTC](https://discourse.julialang.org/t/is-there-a-function-behaving-the-same-as-next-permutation-does-in-c/63451/7 "2021-06-24T03:04:10Z")

</div>

> [@Seif\_Shebl](#):
>
> `nthperm(a, k)` : Compute the `k` th lexicographic permutation of the vector `a` .

So this is pretty confusing. And in Combinatorics.jl, `nthperm([1, 2, 2], 2)` will give `[1, 2, 2]`. So `nthperm(nthperm([1, 2, 2], 2), 2)` will stay at `[1, 2, 2]`, which is not what I need.

---

_[View the full topic](https://discourse.julialang.org/t/is-there-a-function-behaving-the-same-as-next-permutation-does-in-c/63451)._
