made auto-sort algorithm more robust--selects first date column