I need a MySQL stored function that sorts the words (separated by a space) in a string and return the sorted string.
For example :
"The Quick Brown Fox" -> "Brown Fox Quick The"
In PHP this would be an easy task, but in MySQL stored functions I can’t use arrays, so I’m a bit stuck now. I could create a temp table, but this seems so overkill… (and slow).
Any idea’s ?
Many thanks to Bob Vale !
I altered the function he suggested a little bit to specify a custom delimiter.
UPDATE:
This function is not perfect. It produces strangs results when the begin or end of the string is the same as the delimiter, and when there is more than 1 delimiter in a row in the string, so you’ll have to make sure this is not the case in your strings.