/// <summary> /// Sort the collection. /// </summary> /// <typeparam name="T">The type of each element.</typeparam> /// <param name="this">(<see langword="this"/> parameter) The collection.</param> public static void Sort <T>(this IBag <T> @this) where T : notnull { var list = @this.ToList(); list.Sort(); @this.Clear(); @this.AddRange(list); }