@MartinEnder You think you could use Sort by ASCII char code, somehow?
Without adding extra lines of data, this is the best way. Otherwise, you'll probably want to generate all the chars, then replace every char in the target string with the number of its position in the line you generated.
I wrote it with 1-bytes instead, saved it, copied the encode and decode functions from TIO's JavaScript, and then ran encode(decode("originalcodeparameterhere").replace(/\01/g,'\00'))