Example #1
0
		public static void QuickSort(int[][] array, int start, int end, TypeSort type = TypeSort.Max, DirectionSort direction = DirectionSort.Inc) {
			int mid = GetValueFromArr(array[(start + end) / 2], type), i = start, j = end;
			int[] temp;

			while (i <= j)
			{
				if (direction == DirectionSort.Inc) {
					while (GetValueFromArr (array [i], type) < mid)
						i++;
					while (GetValueFromArr (array [j], type) > mid)
						j--;
				} else {
					while (GetValueFromArr (array [i], type) > mid)
						i++;
					while (GetValueFromArr (array [j], type) < mid)
						j--;
				}

				if (i <= j)
				{
					temp = array[i];
					array[i] = array[j];
					array[j] = temp;
					i++;
					j--;
				}
			
				if (i < end)
					QuickSort (array, i, end, type, direction);
				if (j > start)
					QuickSort (array, start, j, type, direction);
			}
		}
        public IQueryable <IEntity> AddOrder <T, TE>(IQueryable <IEntity> list, T typeObject, TE propertyTypeObject, string propertyName, DirectionSort desc) where T : IEntity
        {
            var            orderExpression = GetExpression(typeObject, propertyTypeObject, propertyName);
            IQueryable <T> c;

            switch (desc)
            {
            case DirectionSort.Asc:
                c = ((IQueryable <T>)list).OrderBy(orderExpression);
                break;

            case DirectionSort.Desc:
                c = ((IQueryable <T>)list).OrderByDescending(orderExpression);
                break;

            default:
                c = ((IQueryable <T>)list).OrderBy(orderExpression);
                break;
            }

            return(c as IQueryable <IEntity>);
        }
Example #3
0
 private void radioButton2SortAscending_CheckedChanged(object sender, EventArgs e)
 {
     _directionSort = DirectionSort.Ascending;
 }
Example #4
0
 public CompareMarketPair(DirectionSort direction)
 {
     _directionSort = direction;
 }