Guest User

Untitled

a guest
Jan 20th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. private Color[] OrderColorByHue(List<string> colors)
  2. {
  3. foreach(string c in colors)
  4. {
  5. Color color = ColorFromString(c); // This was defined in another question of mine :)
  6. float hue = color.GetHue();
  7.  
  8. hueColors.Add(new KeyValuePair<Color, float>(color, hue));
  9. }
  10.  
  11. hueColors.Sort((color1, color2) => color2.Value.CompareTo(color1.Value));
  12. Color[] value = hueColors.Select(color => color.Key).ToArray();
  13.  
  14. return value;
  15. }
  16.  
  17. // GET: Admin/Colors
  18. public ActionResult Index()
  19. {
  20. var colors = db.Colors.OrderBy(a => a.HexCode);
  21. return View(colors);
  22. }
Add Comment
Please, Sign In to add comment