public List <DataVisualisationGeneral> SortByDate2(List <DataVisualisationGeneral> flows)
        {
            int n = flows.Count;

            // Start with a big gap,
            // then reduce the gap
            for (int gap = n / 2; gap > 0; gap /= 2)
            {
                // Do a gapped insertion sort for this gap size.
                // The first gap elements a[0..gap-1] are already
                // in gapped order keep adding one more element
                // until the entire array is gap sorted
                for (int i = gap; i < n; i += 1)
                {
                    // add a[i] to the elements that have
                    // been gap sorted save a[i] in temp and
                    // make a hole at position i
                    DateTime temp = flows[i].Date;
                    DataVisualisationGeneral interim = flows[i];

                    // shift earlier gap-sorted elements up until
                    // the correct location for a[i] is found
                    int j;
                    for (j = i; j >= gap && DateTime.Compare(flows[j - gap].Date, temp) < 0; j -= gap)
                    {
                        flows[j] = flows[j - gap];
                    }

                    // put temp (the original a[i])
                    // in its correct location
                    flows[j] = interim;
                }
            }
            return(flows);
        }
        public Category_table(User User, DateTime start, DateTime end, Category category)
        {
            InitializeComponent();
            this.StartDt         = start;
            this.EndDt           = end;
            this.Category        = category;
            this.User            = User;
            TextBlock_start.Text = start.ToShortDateString();
            TextBlock_end.Text   = end.ToShortDateString();
            List <DataVisualisationGeneral> dataVisualisations = new List <DataVisualisationGeneral>();

            if (Category.Name == "Income")
            {
                foreach (Income el in appData.gains)
                {
                    if (User.UID == el.UID && DateTime.Compare(el.TransactionDt, start) >= 0 && DateTime.Compare(el.TransactionDt, end) <= 0)
                    {
                        var datainc = new DataVisualisationGeneral();
                        datainc.Amount  = el.Amount.ToString();
                        datainc.Date    = el.TransactionDt.Date;
                        datainc.Comment = el.Comment;
                        dataVisualisations.Add(datainc);
                    }
                }
            }
            else
            {
                foreach (Spending el in appData.losses)
                {
                    if (User.UID == el.UID && DateTime.Compare(el.TransactionDt, start) >= 0 && DateTime.Compare(el.TransactionDt, end) <= 0 && el.Category == category)
                    {
                        var data = new DataVisualisationGeneral();
                        data.Amount  = el.Amount.ToString();
                        data.Date    = el.TransactionDt.Date;
                        data.Comment = el.Comment;
                        dataVisualisations.Add(data);
                    }
                }
            }
            calculations.SortByDate2(dataVisualisations);
            spendingsList.ItemsSource = dataVisualisations;
        }