3

Вопрос по generics, sorting, c# – Выборочная сортировка списка

Error: User Rate Limit ExceededList<T>Error: User Rate Limit ExceededTError: User Rate Limit ExceededEventError: User Rate Limit ExceededtimeError: User Rate Limit ExceededlongError: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

var events = new ObservableCollection<Event>();
var resp = JsonConvert.DeserializeObject<Events>(restResponse.Content).Items;

var notime = resp.Where(r => r.time == 0);
var yestime = resp.Where(r => r.time > 0);

yestime.ToList().ForEach(events.Add);
notime.ToList().ForEach(events.Add);

CallbackInternal(callback, events);

Error: User Rate Limit ExceededIComparerError: User Rate Limit Exceeded

public class EventComparer : IComparer<Event>
{
    public int Compare(Event x, Event y)
    {
        if (x.time == 0) return 0;
        if (x.time < y.time) return -1;
        if (x.time > y.time) return 1;
        return 0;
    }
}

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

  • Error: User Rate Limit Exceeded.Compare(0, 0)Error: User Rate Limit Exceeded0Error: User Rate Limit Exceeded1.

    от
  • Error: User Rate Limit ExceededelseError: User Rate Limit Exceededreturn

    от
  • Error: User Rate Limit Exceeded

    от
  • Error: User Rate Limit Exceeded

    от
  • Error: User Rate Limit Exceeded

    от
  • Error: User Rate Limit Exceeded

    от earthling
  • Error: User Rate Limit Exceeded

    от
  • Error: User Rate Limit Exceeded

    от
  • Error: User Rate Limit Exceeded

    от earthling
5 ответов
  • 1

    Error: User Rate Limit Exceeded

     if(x.time==y.time) return 0;
     if(x.time==0) return 1;
     return x.time - y.time;
    

  • 2

    Error: User Rate Limit Exceeded

    resp.OrderBy(i => i.time == 0 ? int.MaxValue : i.time);
    

  • 1

    Error: User Rate Limit Exceeded

    0 == 33 > 00 > 33 < 0

    if (x.time == y.time) return 0;
    if (x.time == 0) return 1;
    if (y.time == 0) return -1;
    return x.time.CompareTo(y.time);
    

  • 1

    Error: User Rate Limit Exceeded

        class Comparer : IComparer<int>
        {
            public int Compare(int x, int y)
            {
                if (x == y) return 0;
                else if (x == 0) return 1;
                else if (y == 0) return -1;
                else if (x < y) return -1;
                else if (x > y) return 1;
            }
        }
    

  • 11

    Error: User Rate Limit Exceeded

       events.OrderBy (e => e.Time == 0).ThenBy (e => e.Time);