public static void BuildPriority(Build build, int deltaPriority) { build.Priority += deltaPriority; var bpri = Builds.OrderBy(b => b.Priority).ThenBy(b => b == build ? deltaPriority : 0).ToList(); int i = 1; foreach (var b in bpri) { if (b.Type == BuildType.Lock) { b.Priority = 0; } else { b.Priority = i++; } } }