Repository: files-community/Files
File: src/Files.App/Views/Layouts/BaseLayoutPage.cs (C#)

Code before:
						ItemManipulationModel.FocusSelectedItems();
					}

					// Restart the timer
					jumpTimer.Start();
				}

				jumpString = value;
			}
		}

		private bool isSelectedItemsSorted = false;
		private List<ListedItem>? selectedItems = [];
		public List<ListedItem>? SelectedItems
		{
			get {
				if (!isSelectedItemsSorted)
				{
					var orderedItems = SortingHelper.OrderFileList(selectedItems, FolderSettings.DirectorySortOption, FolderSettings.DirectorySortDirection, FolderSettings.SortDirectoriesAlongsideFiles, FolderSettings.SortFilesFirst).ToList();
					selectedItems = orderedItems;
					isSelectedItemsSorted = true;
				}
				if (SelectedItem is null || !selectedItems!.Contains(SelectedItem))
					return selectedItems;
				else
					return selectedItems.SkipWhile(x => x != SelectedItem).Concat(selectedItems.TakeWhile(x => x != SelectedItem)).ToList();
			}
			internal set
			{
				if (value != selectedItems)
				{
					isSelectedItemsSorted = false;
					selectedItems = value;

					if (selectedItems?.Count == 0 || selectedItems?[0] is null)
					{
						IsItemSelected = false;
						SelectedItem = null;
						SelectedItemsPropertiesViewModel.IsItemSelected = false;

						ResetRenameDoubleClick();
						UpdateSelectionSize();
					}
					else if (selectedItems is not null)
					{
						IsItemSelected = true;
						SelectedItem = selectedItems.First();
						SelectedItemsPropertiesViewModel.IsItemSelected = true;

						UpdateSelectionSize();


Review comment (suggestion):
```suggestion

				return SelectedItem is null || !selectedItems!.Contains(SelectedItem)
					? selectedItems
					: selectedItems
						.SkipWhile(x => x != SelectedItem)
						.Concat(selectedItems.TakeWhile(x => x != SelectedItem))
						.ToList();
```


Code after:
						ItemManipulationModel.FocusSelectedItems();
					}

					// Restart the timer
					jumpTimer.Start();
				}

				jumpString = value;
			}
		}

		private bool isSelectedItemsSorted = false;
		private List<ListedItem>? selectedItems = [];
		public List<ListedItem>? SelectedItems
		{
			get
			{
				if (!isSelectedItemsSorted)
				{
					var orderedItems = SortingHelper.OrderFileList(selectedItems, FolderSettings.DirectorySortOption, FolderSettings.DirectorySortDirection, FolderSettings.SortDirectoriesAlongsideFiles, FolderSettings.SortFilesFirst).ToList();
					selectedItems = orderedItems;
					isSelectedItemsSorted = true;
				}

				return SelectedItem is null || !selectedItems!.Contains(SelectedItem)
					? selectedItems
					: selectedItems
						.SkipWhile(x => x != SelectedItem)
						.Concat(selectedItems.TakeWhile(x => x != SelectedItem))
						.ToList();
			}
			internal set
			{
				if (value != selectedItems)
				{
					isSelectedItemsSorted = false;
					selectedItems = value;

					if (selectedItems?.Count == 0 || selectedItems?[0] is null)
					{
						IsItemSelected = false;
						SelectedItem = null;
						SelectedItemsPropertiesViewModel.IsItemSelected = false;

						ResetRenameDoubleClick();
						UpdateSelectionSize();
					}
					else if (selectedItems is not null)
					{
						IsItemSelected = true;
						SelectedItem = selectedItems.First();