SELECT * FROM MyTable ORDER BY MyTextField Does work if you only want a single sorted direction
But lets say you wanted to sort the first set of chrs asc and the second set descending
First Create a Numbers Table
create table numbers(n integer not null, primary key(n asc));
Second
Insert 1,000,000 rows into the numbers table
This only has to be done once a numbers table is very useful for many complicated queries
insert into numbers(n)
select rowid
from (
select 1
from (
select 0 union select 1 union select 2 union select 3
union select 4 union select 5 union select 6
union select 7 union select 8 union select 9
) a, (
select 0 union select 1 union select 2 union select 3
union select 4 union select 5 union select 6
union select 7 union select 8 union select 9
) b, (
select 0 union select 1 union select 2 union select 3
union select 4 union select 5 union select 6
union select 7 union select 8 union select 9
) c, (
select 0 union select 1 union select 2 union select 3
union select 4 union select 5 union select 6
union select 7 union select 8 union select 9
) d, (
select 0 union select 1 union select 2 union select 3
union select 4 union select 5 union select 6
union select 7 union select 8 union select 9
) e, (
select 0 union select 1 union select 2 union select 3
union select 4 union select 5 union select 6
union select 7 union select 8 union select 9
) f
) derived;
Third
Create and run the following sql statement
Replace all occurrences of t2 with your tablename
Replace all occurrences of myfield with your filed name
See imgdb1.jpg
Select myfield
From(
SELECT
myfield,
substr( myfield, 1, pos-1) AS first,
substr( myfield, pos+1) AS second
FROM (
SELECT
t2.myfield,
numbers.n AS pos
FROM t2
INNER JOIN numbers
WHERE substr(t2.myfield, numbers.n, 1) = '-'
) AS a
ORDER BY first,second
) as b
now change the sort order
order by first,second desc
See Imgdb3.jpg
************************************
The above will also work for sorting customer name fields that contain a single space
Example Bob Smith
Tom Clark
just change this line
WHERE substr(t2.myfield, numbers.n, 1) = '-'
to
WHERE substr(t2.myfield, numbers.n, 1) = ' '