ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sorting (https://www.excelbanter.com/excel-programming/348484-sorting.html)

Dave Unger

Sorting
 
Hi everyone,

Sorry, I can't seem to get the columns to line up in the post.

I'm maintaining a family tree with a spreadsheet, basic components
consist of name and generation index.

| Grandfather's sibling | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| Grandfather | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| Son #1 | 2 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
| Grandson 1- 1 | 2 | 1 | 1 | 0 | 0 | 0 | 0 | 0 |
| Grandson 1-2 | 2 | 1 | 2 | 0 | 0 | 0 | 0 | 0 |
| Son #2 | 2 | 2 | 0 | 0 | 0 | 0 | 0 | 0 |
| Grandson 2-1 | 2 | 2 | 1 | 0 | 0 | 0 | 0 | 0 |
| Grandson 2-1-1 | 2 | 2 | 1 | 1 | 0 | 0 | 0 | 0 |
| Grandson 2-2 | 2 | 2 | 2 | 0 | 0 | 0 | 0 | 0 |
| Grandfather's sibling | 3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |

etc.

Sometimes it's handy to have all the siblings in a generation grouped
together like this:

| Grandfather's sibling | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| Grandfather | 2 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| Grandfather's sibling | 3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| Son #1 | 2 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
| Son #2 | 2 | 2 | 0 | 0 | 0 | 0 | 0 | 0 |
| Grandson 1-1 | 2 | 1 | 1 | 0 | 0 | 0 | 0 | 0 |
| Grandson 1-2 | 2 | 1 | 2 | 0 | 0 | 0 | 0 | 0 |
| Grandson 2-1 | 2 | 2 | 1 | 0 | 0 | 0 | 0 | 0 |
| Grandson 2-2 | 2 | 2 | 2 | 0 | 0 | 0 | 0 | 0 |
| Grandson 2-1-1 | 2 | 2 | 1 | 1 | 0 | 0 | 0 | 0 |

This one has me stumped, and I've got myself in a rut thinking about
it. As a workaround, I have a routine that builds a secondary index,
which will produce the desired result using "normal" sorting.
Basically, it's a copy of the regular index, with all the non-zero
digits shifted to the extreme right.

| Grandfather's sibling | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
| Grandfather | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 |
| Son #1 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 1 |
| Grandson 1- 1 | 0 | 0 | 0 | 0 | 0 | 2 | 1 | 1 |
| Grandson 1-2 | 0 | 0 | 0 | 0 | 0 | 2 | 1 | 2 |
| Son #2 | 0 | 0 | 0 | 0 | 0 | 2 | 2 | 0 |
| Grandson 2-1 | 0 | 0 | 0 | 0 | 0 | 2 | 2 | 1 |
| Grandson 2-1-1 | 0 | 0 | 0 | 0 | 2 | 2 | 1 | 1 |
| Grandson 2-2 | 0 | 0 | 0 | 0 | 0 | 2 | 2 | 2 |
| Grandfather's sibling | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 |

While this does work, it seems like a clumsy method, as well as adding
a lot of data to an already large file. One idea I had was to combine
each persons index into one integer, and shift it with some simple
math, but the fact that some of the older generations had more than 9
kids complicated things.

If anyone has any ideas, I would be glad to hear them.

Thanks,

DaveU



All times are GMT +1. The time now is 04:48 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com