java app to sort images according to the parameter