I have a spreadsheet that contains a column with people their ZIP code and another with an ID that is assigned to them.
I would like to sort this sheet by the ID column, but also have all people with the same ZIP code grouped together.
A priority list of which row should appear next would be as follows.
- The next lowest ID with the same ZIP code as the previous entry.
- The next lowest ID
As an algorithmic implementation this would be fairly simple, but I can't figure out how to do this with Excel options.
What I've tried and failed at is first sorting by ZIP code and then by the ID, but this only groups the zip codes together and sorts the IDs for each ZIP code correctly. It doesn't make the first ID be on top, but rather the first ZIP code.
I have also tried creating groups for each ZIP code, but if I then sort by ID the groups do not stay together.
Some sample data would be:
ID ZIP TR-002 7586 KO TR-004 7896 KL TR-007 7586 KO TR-012 7493 KP TR-088 6868 KK TR-101 7493 KP
Which I want sorted as:
ID ZIP TR-002 7586 KO TR-007 7586 KO TR-004 7896 KL TR-012 7493 KP TR-101 7493 KP TR-088 6868 KK