public static void Sort(this GridViewColumnHeader column)
        {
            if (column != null)
            {
                ListView parent = column.ParentListView();
                if (parent != null)
                {
                    if (!GetIsSorting(parent))
                    {
                        SetIsSorting(parent, true);
                        string   fieldxxx  = GetSortColumnID(column);
                        string[] fieldList = null;
                        string   field     = null;
                        if (!string.IsNullOrEmpty(fieldxxx))
                        {
                            fieldList = fieldxxx.Split('|');
                            if (fieldList.Length == 1)
                            {
                                field = fieldList[0];
                            }
                        }


                        //TODO: Allow compound column fields.


                        GridViewColumnHeader _CurSortCol = GetCurrentSortColumn(parent);


                        SortAdorner _CurAdorner = GetCurrentSortAdorner(parent);


                        if (fieldList != null)
                        {
                            ListCollectionView dataView = CollectionViewSource.GetDefaultView(parent.ItemsSource) as ListCollectionView;
                            if (dataView != null)
                            {
                                if (_CurSortCol != null)
                                {
                                    AdornerLayer.GetAdornerLayer(_CurSortCol).Remove(_CurAdorner);
                                    dataView.SortDescriptions.Clear();
                                    parent.Items.SortDescriptions.Clear();
                                }
                                else
                                {
                                    if (_CurAdorner != null)
                                    {
                                        AdornerLayer.GetAdornerLayer(parent).Remove(_CurAdorner);
                                        dataView.SortDescriptions.Clear();
                                        parent.Items.SortDescriptions.Clear();
                                    }
                                }
                                ListSortDirection newDir = GetSortDirection(column);


                                _CurAdorner = new SortAdorner(column, newDir);



                                AdornerLayer.GetAdornerLayer(column).Add(_CurAdorner);


                                SetCurrentSortColumn(parent, column);

                                SetCurrentSortAdorner(parent, _CurAdorner);

                                IComparer sorter = null;

                                if (fieldList.Length > 1)
                                {
                                    if (MultipleColumnSorter.IsCandidate(dataView.ItemProperties, fieldList))
                                    {
                                        if (newDir == ListSortDirection.Ascending)
                                        {
                                            sorter = new MultipleColumnSorter(fieldList);
                                        }
                                        else
                                        {
                                            sorter = new ReverseMultipleColumnSorter(fieldList);
                                        }
                                    }
                                    else
                                    {
                                        foreach (string f in fieldList)
                                        {
                                            dataView.SortDescriptions.Add(new SortDescription(f, newDir));
                                        }
                                    }
                                }
                                else
                                {
                                    foreach (ItemPropertyInfo p in dataView.ItemProperties)
                                    {
                                        if (p.Name.ToUpperInvariant() == field.ToUpperInvariant())
                                        {
                                            Type ptype = p.GetType();
                                            if (ptype == typeof(DateTime))
                                            {
                                                if (newDir == ListSortDirection.Ascending)
                                                {
                                                    sorter = new DateSorter();
                                                }
                                                else
                                                {
                                                    sorter = new ReverseDateSorter();
                                                }
                                            }
                                            else if (ptype == typeof(IComparable))
                                            {
                                                if (newDir == ListSortDirection.Ascending)
                                                {
                                                    sorter = new ComparableSorter();
                                                }
                                                else
                                                {
                                                    sorter = new ReverseComparableSorter();
                                                }
                                            }
                                            break;
                                        }
                                    }

                                    if (sorter == null)
                                    {
                                        dataView.SortDescriptions.Add(new SortDescription(field, newDir));
                                    }
                                    else
                                    {
                                        dataView.CustomSort = sorter;
                                    }
                                }
                                dataView.Refresh();
                            }
                        }
                        SetIsSorting(parent, false);
                    }
                }
            }
        }