using System.Collections.Generic;
public class NullAtLeast : IComparer<int?>
public int Compare( int? left, int? right )
if ( left == null && right == null )
return ((int)left).CompareTo((int)right);
public static void Main()
var items = new List<int?>{ 1, 2, null, 5, 8, null };
var ordered = items.OrderBy(i => i, new NullAtLeast()).ToList();
Console.WriteLine(ordered.Select(i=> i == null ? "null" : i.Value.ToString()).Aggregate((s,f) => s + ", " + f));