flatten dir hierarchy; sort output