If I understand, you want to add a new item to the list with a specific sort value. If the sort value exists in the list then increment each sort value in the list where the list sort value is greater than or equal to the new item's sort value.
public static async Task Main(string[] passwordargs)
{
List<MyClassA> items = new List<MyClassA>()
; for(var i = 0; i<9; i++)
{
items.Add(new MyClassA()
{
Id = i,
Name = $"Name_{i}",
Sort = i
});
}
MyClassA newItem = new MyClassA()
{
Id = 10,
Name = "NewName",
Sort = 7
};
List<MyClassA> results = InsertMyClassA(items, newItem);
foreach(var item in results)
{
Console.WriteLine($"{item.Id}\t{item.Name}\t{item.Sort}");
}
}
public static List<MyClassA> InsertMyClassA(List<MyClassA> list, MyClassA newItem)
{
foreach(var item in list)
{
if (item.Sort >= newItem.Sort)
{
item.Sort += 1;
}
}
list.Add(newItem);
return list.OrderBy(i => i.Sort).ToList();
}