1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21:
select * from ( select *, case when substr(t,2,1) regexp '[0-9]' then left(t,1) when substr(t,3,1) regexp '[0-9]' then left(t,2) else left(t,3) end branch, case when substr(t,2,1) regexp '[0-9]' then cast(substr(t,2,i-2) as SIGNED) when substr(t,3,1) regexp '[0-9]' then cast(substr(t,3,i-3) as SIGNED) when substr(t,4,1) regexp '[0-9]' then cast(substr(t,4,i-4) as SIGNED) end rack, cast(substr(t,i+1,length(t)) as SIGNED) level from ( select t, case when instr(t,"-") > 0 then instr(t,"-") else length(t)+1 end as i from customsort ) SQ ) SQ2 order by branch, rack, level