using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace Linearis_programozas
{
    class SorComparer : IComparer
    {
        public SorComparer() : base() { }
        
        int IComparer.Compare(object x, object y)
        {

            Col_sor Col_sorX = (Col_sor)x;
            Col_sor Col_sorY = (Col_sor)y;

            if (Col_sorX == null && Col_sorY == null)
            {
                return 0;
            }
            else if (Col_sorX == null && Col_sorY != null)
            {
                return  -1;
            }
            else if (Col_sorX != null && Col_sorY == null)
            {
                return 1;
            }
            else
            {
                if (Col_sorX.Celfg_e == Col_sorY.Celfg_e) return Col_sorX.Valtozo.CompareTo(Col_sorY.Valtozo);


                //if (Col_sorX.Celfg_e == true) return -1;
                //if (Col_sorY.Celfg_e == true) return 1;

                if (Col_sorX.Celfg_e == true) return (Col_sorX.Valtozo+"a").CompareTo(Col_sorY.Valtozo+"b");
                if (Col_sorY.Celfg_e == true) return (Col_sorX.Valtozo + "b").CompareTo(Col_sorY.Valtozo + "a");

                else return Col_sorX.Valtozo.CompareTo(Col_sorY.Valtozo);
                 //return (this.m_direction == SortDirection.Ascending) ?
                 //personX.Age.CompareTo(personY.Age) :
                 //personY.Age.CompareTo(personX.Age);
            }
        }
    }
}
