sorting in calc

Hello all,
Ive managed to solve my problem in a roundabout way. To give the context, i have a column containing strings of length 1 to 3 which may contain nonstandard characters and which i must sort in a specific order (not the usual alphabetic order). To achieve this i have a table assigning a number (col B) to each char (col A) in sheet 2, defined as a range 'xlit'. On sheet 1 column A has strings to be sorted, columns B-D contain number to represent char 1,2,3 of the string. I obtain these numbers as text, using a formula of the form =IFERROR(TEXT(VLOOKUP(MID (Ax,y,1),xlit,2,0),"General"")," ")
where x is the row containing the string and y is 1,2 or 3 for the appropriate char of the string, returning the number as a string or " "if the character doesnt exist (string is of shorter length). I can now order my strings by sorting on columns B,C,D in that order. Perhaps there might have been an easier way to do it, but it works and thats what counts
Gary