Labeling all layers in Linearithmic O(n log n) time