private async void OnRefresh() { IsBusy = true; await Task.Yield(); // Clear the list or you'll get duplicates upon resuming Races.Clear(); // get the list of races IEnumerable <Race> races = await _dataService.GetRacesAsync(); var previous = new Group <Race>() { Name = "Previous Races" }; var current = new Group <Race>() { Name = "Current Races" }; var future = new Group <Race>() { Name = "Upcoming Races" }; var now = DateTimeOffset.Now; foreach (var race in races) { if (race.StartDate > now) { future.Add(race); } else if (race.EndDate < now) { previous.Add(race); } else { current.Add(race); } } // sort items current.Sort(i => i.StartDate ?? DateTimeOffset.MinValue); future.Sort(i => i.StartDate ?? DateTimeOffset.MinValue); previous.SortDescending(i => i.EndDate ?? DateTimeOffset.MaxValue); Races .AddGroupIfNotEmpty(current) .AddGroupIfNotEmpty(future) .AddGroupIfNotEmpty(previous); IsBusy = false; }