learning linq: quicksort
i took thrust afternoon began study linq, distant only mucking around linq collections. initial things i attempted exercise qsort.
now -- ignoring fact i could only an orderby unequivocally stupid qsort doing -- i came adult this:
public category lqsort
{
open stationary list<int> qslinq(list<int> _items)
{
(_items.count <= 1)
relapse _items;
int _pivot = _items[0];
list<int> _less = (from _item _items where _item < _pivot name _item).tolist();
list<int> _same = (from _item _items where _item == _pivot name _item).tolist();
list<int> _greater = (from _item _items where _item > _pivot name _item).tolist();
relapse (qslinq(_less).concat(_same.concat(qslinq(_greater)))).tolist();
}
}
the wholly thing unequivocally bugs me casting involved. there any linq tricks i competence use? am i only controlling linq things wasn't commanded for?
Comments
Post a Comment