The idea behind the solution is to make the rows be numbered from 1 and up based on the provider. if the rows with type 'a' where numbered from 1..4 and rows with type 'b' where numbered from 1 ..3 and rows with type 'c' where numbered from 1..3, then you can easily get what you wanted with using "order by" on these numbers.
for the example, i will suppose that your table name is "my_table" and it has two fields, type and data.
in order to make rownum in mysql, i will use what was described here: rownum in mysql
now lets suppose we want to select all rows with type 'a' and give them ascending row number. we can do it like the following:
select type,data,@rownuma := @rownuma+1 as order_num
from my_table,(select @rownuma:=0) ra
where type='a'
we can do the same for the other types, then union all the results, and then wrap them in an outer select that does the ordering. the answer to your question would be the following query:
select type,data
from
(
select type,data,@rownuma := @rownuma+1 as order_num
from my_table,(select @rownuma:=0) ra
where type='a'
union all
select type,data,@rownumb := @rownumb+1 as order_num
from my_table,(select @rownumb:=0) rb
where type='b'
union all
select type,data,@rownumc := @rownumc+1 as order_num
from my_table,(select @rownumc:=0) rc
where type='c'
) in_tab
order by order_num,type
note that for each type we define a different variable to do the counter.
as a final note, you could do it with defining all counters in the same join and then you don't use the union all, but instead in the select you can use the correct variable based on the type. the following is an equal query
select type,data
from
(
select type,data,
case when type='a' then @rownuma := @rownuma+1
when type='b' then @rownumb := @rownumb+1
when type='c' then @rownumc := @rownumc+1
end as order_num
from my_table, (select @rownuma:=0) ra, (select @rownumb:=0) rb, (select @rownumc:=0) rc
) in_tab
order by order_num,type
the second version is even better if you have more conditions (where clause) for selecting the rows as you won't need to repeat them in every sub query that is part of the union in the first version.