public void sort(Apartment[] apartments, string sortBy, int left, int right) { int i = left, j = right; IComparable pivot = apartments[(left + right) / 2].getAttribute(sortBy); while (i <= j) { while (apartments[i].getAttribute(sortBy).CompareTo(pivot) < 0) { i++; } while (apartments[j].getAttribute(sortBy).CompareTo(pivot) > 0) { j--; } if (i <= j) { Apartment tmp = apartments[i]; apartments[i] = apartments[j]; apartments[j] = tmp; i++; j--; } } // Recursive calls if (left < j) { sort(apartments, sortBy, left, j); } if (i < right) { sort(apartments, sortBy, i, right); } }
public MainAdapter(Activity context, Apartment[] items) : base() { this.context = context; this.items = items; }