fork(5) download
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. class Vehicles {
  6. public string VehId { get; set; }
  7. public string VehName { get; set; }
  8. }
  9. public class Test
  10. {
  11. public static void Main()
  12. {
  13. List<Vehicles> vehicles = new List<Vehicles>() {
  14. new Vehicles(){VehId="LOR",VehName="Lorry"},
  15. new Vehicles(){VehId="CAR",VehName="Car"},
  16. new Vehicles(){VehId="BOA",VehName="Boat"},
  17. new Vehicles(){VehId="PLN",VehName="Plane"},
  18. };
  19. var ordered = vehicles
  20. .OrderByDescending(v => v.VehId == "CAR")
  21. .ThenBy(v => v.VehName);
  22. Console.WriteLine(string.Join(", ", ordered.Select(v => v.VehId + " "+ v.VehName).ToArray()));
  23. }
  24. }
Success #stdin #stdout 0.05s 37192KB
stdin
Standard input is empty
stdout
CAR Car, BOA Boat, LOR Lorry, PLN Plane