rework parameter handling, add sort options

Change-Id: Icd750fd95b3939d602e72ba330f41b7e45a14e63