Find the minimum sequence number for each id. You can do this using analytics.
You can then order by this, then the sequence number:
create table t (id varchar2(5), class integer, sequence int);
insert into t values ('126A', 7000, 1);
insert into t values ('127B', 7000, 2);
insert into t values ('130A', 7000, 3);
insert into t values ('130B', 7000, 4);
insert into t values ('125B', 6000, 5);
insert into t values ('126A', 6000, 6);
insert into t values ('127B', 6000, 7);
insert into t values ('130A', 6000, 8);
commit;
select * from (
select t.*,
min(sequence) over (partition by id) mn
from t
)
order by mn, sequence;
ID CLASS SEQUENCE MN
----- ---------- ---------- ----------
126A 7000 1 1
126A 6000 6 1
127B 7000 2 2
127B 6000 7 2
130A 7000 3 3
130A 6000 8 3
130B 7000 4 4
125B 6000 5 5
8 rows selected
You can simplify this to:
select t.*
from t
order by min(sequence) over (partition by id) , sequence
ID CLASS SEQUENCE
----- ---------- ----------
126A 7000 1
126A 6000 6
127B 7000 2
127B 6000 7
130A 7000 3
130A 6000 8
130B 7000 4
125B 6000 5
8 rows selected