/// <summary> /// Sorts the elements in the entire <see cref="T:System.Collections.Generic.List`1"/> using the specified comparer. /// </summary> /// <param name="comparer">The <see cref="T:System.Collections.Generic.IComparer`1"/> implementation to use when comparing elements, or null to use the default comparer <see cref="P:System.Collections.Generic.Comparer`1.Default"/>.</param><exception cref="T:System.InvalidOperationException"><paramref name="comparer"/> is null, and the default comparer <see cref="P:System.Collections.Generic.Comparer`1.Default"/> cannot find implementation of the <see cref="T:System.IComparable`1"/> generic interface or the <see cref="T:System.IComparable"/> interface for type <paramref name="T"/>.</exception><exception cref="T:System.ArgumentException">The implementation of <paramref name="comparer"/> caused an error during the sort. For example, <paramref name="comparer"/> might not return 0 when comparing an item with itself.</exception> public void Sort(IComparer <T> comparer) { if (comparer == null) { throw new ArgumentNullException("comparer"); } if (Count <= 0) { return; } storage.sort(Jsni.function((x, y) => comparer.Compare(x.As <T>(), y.As <T>()).As <JsNumber>())); }
public void IndexerOverride() { Jsni.reference("window").memberset("IndexerOverride", Jsni.@object(new { items = Jsni.array(), item = Jsni.function((index, value) => { if (Jsni.arguments().As <JsArray>().length == 1) { return(Jsni.@this().member("items").As <JsArray>()[index]); } else { Jsni.@this().member("items").As <JsArray>()[index] = value; return(null); } }) })); var indexerOverride = Jsni.reference("window").member("IndexerOverride").As <IndexerOverrideClass>(); indexerOverride[3] = "foo"; QUnit.AreEqual(indexerOverride[3], "foo"); }