Example #1
0
        public virtual PropertyDescriptorCollection Sort(string[] order, IComparer comparer)
        {
            PropertyDescriptorCollection col = CloneCollection();
            ArrayList sorted = col.ExtractItems(order);

            col.InternalSort(comparer);
            sorted.AddRange(col.properties);
            col.properties = sorted;
            return(col);
        }
        /// <summary>Sorts the members of this collection. The specified order is applied first, followed by the sort using the specified <see cref="T:System.Collections.IComparer" />.</summary>
        /// <returns>A new <see cref="T:System.ComponentModel.PropertyDescriptorCollection" /> that contains the sorted <see cref="T:System.ComponentModel.PropertyDescriptor" /> objects.</returns>
        /// <param name="names">An array of strings describing the order in which to sort the <see cref="T:System.ComponentModel.PropertyDescriptor" /> objects in this collection. </param>
        /// <param name="comparer">A comparer to use to sort the <see cref="T:System.ComponentModel.PropertyDescriptor" /> objects in this collection. </param>
        public virtual PropertyDescriptorCollection Sort(string[] order, IComparer comparer)
        {
            PropertyDescriptorCollection propertyDescriptorCollection = this.CloneCollection();

            if (order != null)
            {
                ArrayList arrayList = propertyDescriptorCollection.ExtractItems(order);
                propertyDescriptorCollection.InternalSort(comparer);
                arrayList.AddRange(propertyDescriptorCollection.properties);
                propertyDescriptorCollection.properties = arrayList;
            }
            else
            {
                propertyDescriptorCollection.InternalSort(comparer);
            }
            return(propertyDescriptorCollection);
        }