you won't need to extract anything from the keys, they are purely for sorting.
once sorted you should already have the data you need in the original objects
the more weight you want any key to have you just ensure that those bits are more significant
so if you want to prioritise material, then just make sure that its bits are shifted higher.
your play around above is a great start in the right direction!
just sort your objects based on that uint and boom - roll in your success.