perl library to sort input to look like given example data