public void Sort()
        {
            var list = _listViewItemCollection.Cast <TreeViewItem>().ToList();

            list.Sort((x, y) =>
            {
                if (x is StoreCategorizeTreeViewItem)
                {
                    if (y is StoreCategorizeTreeViewItem)
                    {
                        var vx = ((StoreCategorizeTreeViewItem)x).Value;
                        var vy = ((StoreCategorizeTreeViewItem)y).Value;

                        int c = vx.Name.CompareTo(vy.Name);
                        if (c != 0)
                        {
                            return(c);
                        }
                        c = vx.StoreTreeItems.Count.CompareTo(vy.StoreTreeItems.Count);
                        if (c != 0)
                        {
                            return(c);
                        }
                        c = vx.GetHashCode().CompareTo(vy.GetHashCode());
                        if (c != 0)
                        {
                            return(c);
                        }
                    }
                    else if (y is StoreTreeViewItem)
                    {
                        return(-1);
                    }
                }
                else if (x is StoreTreeViewItem)
                {
                    if (y is StoreTreeViewItem)
                    {
                        var vx = ((StoreTreeViewItem)x).Value;
                        var vy = ((StoreTreeViewItem)y).Value;

                        int c = vx.Signature.CompareTo(vy.Signature);
                        if (c != 0)
                        {
                            return(c);
                        }
                        c = vx.Boxes.Count.CompareTo(vy.Boxes.Count);
                        if (c != 0)
                        {
                            return(c);
                        }
                        c = vx.GetHashCode().CompareTo(vy.GetHashCode());
                        if (c != 0)
                        {
                            return(c);
                        }
                    }
                    else if (y is StoreCategorizeTreeViewItem)
                    {
                        return(1);
                    }
                }

                return(0);
            });

            for (int i = 0; i < list.Count; i++)
            {
                var o = _listViewItemCollection.IndexOf(list[i]);

                if (i != o)
                {
                    _listViewItemCollection.Move(o, i);
                }
            }
        }
        public void Sort()
        {
            var list = _children.Cast <TreeViewModelBase>().ToList();

            list.Sort((x, y) =>
            {
                if (x is ChatCategorizeTreeViewModel)
                {
                    if (y is ChatCategorizeTreeViewModel)
                    {
                        var vx = ((ChatCategorizeTreeViewModel)x).Value;
                        var vy = ((ChatCategorizeTreeViewModel)y).Value;

                        int c = vx.Name.CompareTo(vy.Name);
                        if (c != 0)
                        {
                            return(c);
                        }
                        c = vx.ChatTreeItems.Count.CompareTo(vy.ChatTreeItems.Count);
                        if (c != 0)
                        {
                            return(c);
                        }
                        c = vx.GetHashCode().CompareTo(vy.GetHashCode());
                        if (c != 0)
                        {
                            return(c);
                        }
                    }
                    else if (y is ChatTreeViewModel)
                    {
                        return(1);
                    }
                }
                else if (x is ChatTreeViewModel)
                {
                    if (y is ChatTreeViewModel)
                    {
                        var vx = ((ChatTreeViewModel)x).Value;
                        var vy = ((ChatTreeViewModel)y).Value;

                        int c = vx.Tag.Name.CompareTo(vy.Tag.Name);
                        if (c != 0)
                        {
                            return(c);
                        }
                        c = CollectionUtils.Compare(vx.Tag.Id, vy.Tag.Id);
                        if (c != 0)
                        {
                            return(c);
                        }
                        c = vx.GetHashCode().CompareTo(vy.GetHashCode());
                        if (c != 0)
                        {
                            return(c);
                        }
                    }
                    else if (y is ChatCategorizeTreeViewModel)
                    {
                        return(-1);
                    }
                }

                return(0);
            });

            for (int i = 0; i < list.Count; i++)
            {
                var o = _children.IndexOf(list[i]);

                if (i != o)
                {
                    _children.Move(o, i);
                }
            }
        }