add helper function to sort by time dimension #319

Added helper function with test.