The traditional (and still readable) reference for generating combinatorial objects such as permutations is Nijenhuis & Wilf's Combinatorial Algorithms.
The author of the article ubiquitously misspells "lexicographic" as "lexographic." That might make it harder to Google the term.
[1] https://www.princeton.edu/~rblee/ELE572Papers/p137-sedgewick...
Note: Enjoy discriminating between the one and the lower-case l.
subroutine hpsort(n,b)
integer b(500),bstar
n1=n
l=1+n/2
11 l=l-1
bstar=b(l)
goto 30
25 bstar=b(n1)
b(n1)=b(1)
29 n1=n1-1
30 l1=l
31 m=2*l1
if(m-n1)32,33,37
32 if(b(m+1).ge.b(m)) m=m+1
33 if(bstar.ge.b(m))goto 37
b(l1)=b(m)
l1=m
goto 31
37 b(l1)=bstar
if(l.gt.1)goto 11
if(n1.ge.2)goto 25
return
end