Class RandomListItemClass RandomListItem Implements System.IComparable Public Value AsObject Public RandomRight AsDouble PublicFunction CompareTo()Function CompareTo(ByVal obj AsObject) AsIntegerImplements System.IComparable.CompareTo Dim o As RandomListItem = obj ReturnMe.RandomRight - o.RandomRight End Function End Class PublicClass FactoryClass Factory Dim Base As System.Collections.SortedList Sub New()SubNew() Base =New SortedList End Sub PublicSub Add()Sub Add(ByVal value AsObject) Dim r AsNew System.Random Dim i AsNew RandomListItem i.Value = value i.RandomRight = r.NextDouble r =Nothing Base.Add(Common.MD5CodeStr(i.RandomRight & Now), i) End Sub PublicSub AddArray()Sub AddArray(ByVal values AsObject()) Dim r AsNew System.Random ForEach value AsObjectIn values Dim i AsNew RandomListItem i.Value = value i.RandomRight = r.NextDouble Base.Add(Common.MD5CodeStr(i.RandomRight & Now), i) Next r =Nothing End Sub PublicFunction ToArray()Function ToArray(OptionalByVal ArraySize As Int32 =-1) AsObject() If ArraySize =-1Then ArraySize = Base.Count If ArraySize > Base.Count -1Then ArraySize = Base.Count Dim tmpa() As Collections.DictionaryEntry IfNot Base.Count =0ThenReDim tmpa(Base.Count -1) Dim r() AsObject IfNot Base.Count =0ThenReDim r(ArraySize -1) Base.CopyTo(tmpa, 0) For i As Int32 =0To r.Length -1 Dim ti As RandomListItem = tmpa(i).Value r(i) = ti.Value Next Return r End Function PublicFunction ToHashTable()Function ToHashTable() As Hashtable Dim x AsNew Hashtable ForEach i As RandomListItem In Base x.Add(Base.GetKey(Base.IndexOfValue(i)), i.Value) Next Return x End Function PublicSub RebuildOrder()Sub RebuildOrder() ForEach i As RandomListItem In Base Dim r AsNew System.Random i.RandomRight = r.NextDouble r =Nothing Next End Sub End Class