How would I rearrange the lines in the file (...) to match the order (...)?
If you want to compare two list, you can achieve that by using
Linq[
^]. So, there's no need to rearrange anything.
Dim lines1 As String() = {"prop1:aaa", "-", "prop3:ccc", "prop2:bbb", "-"}
Dim lines2 As String() = {"prop1:aaa", "-", "prop2:bbb", "-", "prop3:ccc"}
Dim orderedlist1 = lines1 _
.Where(Function(s) s.Contains(":")) _
.Select(Function(s) New With _
{ _
Key .PropertyName = s.Split(":")(0), _
Key .DefaultValue = s.Split(":")(1) _
}) _
.OrderBy(Function(item) item.PropertyName) _
.ToList()
Dim orderedlist2 = lines2 _
.Where(Function(s) s.Contains(":")) _
.Select(Function(s) New With _
{ _
Key .PropertyName = s.Split(":")(0), _
Key .DefaultValue = s.Split(":")(1) _
}) _
.OrderBy(Function(item) item.PropertyName) _
.ToList()
Result (
orderedlist1
and
orderedlist2
are exactly the same):
PropertyName DefaultValue
prop1 aaa
prop2 bbb
prop3 ccc
To compare them, use
Enumerable.Except method[
^]:
Dim result = orderedlist1.Except(orderedlist2).Count()