There is a function:
Clear[sort]; sort[{a___, b_, c_, d___}] := {a, c, b, d} /; b > c;
It perfectly works with NestList function:
NestList[sort, {5, 4, 3, 2, 1}, 10]
{{5, 4, 3, 2, 1}, {4, 5, 3, 2, 1}, {4, 3, 5, 2, 1}, {3, 4, 5, 2,
1}, {3, 4, 2, 5, 1}, {3, 2, 4, 5, 1}, {2, 3, 4, 5, 1}, {2, 3, 4, 1,
5}, {2, 3, 1, 4, 5}, {2, 1, 3, 4, 5}, {1, 2, 3, 4, 5}}
But it isn't working with FixedPointList:
FixedPointList[sort, {5, 4, 3, 2, 1}]
It seems like infinite loop, the program just evaluating something without stop. What's the reason of such behaviour and how can I fix my function to make it work?
NestList[sort, {5, 4, 3, 2, 1}, 13]
and you should see why FixedPointList never finishes. $\endgroup$