let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
tbl = Table.AddIndexColumn(Source, "Index", 0, 1, Int64.Type),
tbl1 = Table.AddColumn(tbl, "Custom", each try if [Name]<> tbl[Name]{[Index]-1} then true else false otherwise true),
tbl2 = Table.Group(tbl1, {"Name"}, {{"All", each _}}),
tbl3 = Table.TransformColumns(tbl2, {"All", each Table.AddIndexColumn(_, "Index1", 1, 1, Int64.Type)}),
CountTrue = (tbl as table, col as text, idx as number) as number => List.Count(List.Select(List.FirstN(Table.Column(tbl, col), idx), each _=true)),
tbl4 = Table.TransformColumns(tbl3, {"All", each Table.AddColumn(_, "Order", (x)=> CountTrue(_, "Custom", x[Index1]))}),
tbl5 = Table.ExpandTableColumn(tbl4, "All", {"Index", "Order"}),
tbl6 = Table.Sort(tbl5,{{"Index", Order.Ascending}}),
Result = Table.RemoveColumns(tbl6,{"Index"})
in
Result