added -r option to reverse sort order