This results from an idea by Philip Cohen, noted by A. Ross Eckler in 1981’s Alphabetizing the Integers, which was used recently to formalize and extend an existing sequence in the OEIS. I struggled to make Mathematica do what it needed to do. Worse, it took me most of a day to generate the ten thousand terms that a co-author of the sequence managed in minutes using Python.
I wanted something like
SortBy[Range[13],IntegerName]
{8,11,5,4,9,1,7,6,10,13,3,12,2}
and then pick out the fixed points (integers at their sequence position: {4,7,12}). Unfortunately, this SortBy procedure doesn’t do a true AlphabeticSort as evidenced by doing Range[800] where the 18 appears before the 800 in the output (an alphabetic sort should have a space precede any letter). We also need IntegerName to default to “Words”, the full letters-only descriptor. Another caveat is that we need to strip the commas out of all our IntegerName conversions prior to sorting. Failing to do so might compromise the number of items in our word list (as commas are used as list delimiters). I finally settled on this clunker:
Do[w=AlphabeticSort[Table[StringReplace[IntegerName[n,"Words"],{","->"","-"->"-"}],{n,i}]];k={};Do[If[StringReplace[IntegerName[j,"Words"],{","->"","-"->"-"}]==w[[j]],AppendTo[k,j]],{j,i}];Print[i," ",k],{i,13}]
1 {1}
2 {1,2}
3 {1}
4 {3}
5 {}
6 {}
7 {}
8 {6}
9 {}
10 {}
11 {4,7}
12 {4,7}
13 {4,7,12}
In addition to stripping the commas from IntegerName, I replaced the special (character code 8208) hyphen with the generic (character code 45) hyphen. That’s because I don’t know how AlphabeticSort deals with hyphens in words and, anyhow, I have to share results with people who use generic hyphens. Once I have my alphabetically-sorted list, I have to recapture their numeric equivalents by doing the StringReplace all over again.
[1]: https://digitalcommons.butler.edu/cgi/viewcontent.cgi?article=2556&context=wordways
[2]: A340671 - OEIS
