SHARE
TWEET

Untitled

a guest Aug 28th, 2017 186 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.             var groupedTag = records.GroupBy(r => r.TagName);
  2.  
  3.             var winner = groupedTag.OrderBy(GT =>
  4.            {
  5.                float finalChange = 0.0f;
  6.                foreach (var item in GT)
  7.                {
  8.                    float thisItem = (float)item.QuestionCount / (float)item.YearTotalCount;
  9.                    var nextItem = GT.Where(i2 => item.Year + 1 == i2.Year).FirstOrDefault();
  10.  
  11.                    if (!object.Equals(nextItem, default(YearlyQuestionData)) && nextItem.Year != 2017)
  12.                        finalChange += (float)(((float)nextItem.QuestionCount / (float)nextItem.YearTotalCount) - (float)thisItem);
  13.                }
  14.  
  15.                return finalChange;
  16.            }).Reverse().Take(5);
  17.  
  18.             foreach (var item in winner)
  19.             {
  20.                 Console.WriteLine(item.FirstOrDefault().TagName);
  21.  
  22.                 foreach (var item2 in item)
  23.                 {
  24.                     Console.WriteLine($"{item2.Year,-5} | {((float)((float)item2.QuestionCount / (float)item2.YearTotalCount)).ToString(".0####"),-7} | {item2.QuestionCount}");
  25.                 }
  26.             }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top