reorder libraries to reflect library dependency chain