Advertisement
Guest User

Untitled

a guest
Aug 28th, 2017
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement