Index: TECH/Algo/Sort/MergeSort.cls.xml =================================================================== diff -u -r423 -r424 --- TECH/Algo/Sort/MergeSort.cls.xml (.../MergeSort.cls.xml) (revision 423) +++ TECH/Algo/Sort/MergeSort.cls.xml (.../MergeSort.cls.xml) (revision 424) @@ -33,30 +33,32 @@ 1 %ListOfDataTypes 0) || (Rechts.Count() > 0) + #dim LinksIndex As %Integer = 1 + #dim RechtsIndex As %Integer = 1 + While (Links.Count() > (LinksIndex-1)) || (Rechts.Count() > (RechtsIndex-1)) { - If (Links.Count() > 0) && (Rechts.Count() > 0) + If (Links.Count() > (LinksIndex-1)) && (Rechts.Count() > (RechtsIndex-1)) { - If Comparator.IsKleinerDan(Links.GetAt(1),Rechts.GetAt(1)) + If Comparator.IsKleinerDan(Links.GetAt(LinksIndex),Rechts.GetAt(RechtsIndex)) { - Do Target.Insert(Links.GetAt(1)) - Do Links.RemoveAt(1) + Do Target.Insert(Links.GetAt(LinksIndex)) + Set LinksIndex = LinksIndex + 1 } Else { - Do Target.Insert(Rechts.GetAt(1)) - Do Rechts.RemoveAt(1) + Do Target.Insert(Rechts.GetAt(RechtsIndex)) + Set RechtsIndex = RechtsIndex + 1 } } - ElseIf (Links.Count() > 0) + ElseIf (Links.Count() > (LinksIndex-1)) { - Do Target.Insert(Links.GetAt(1)) - Do Links.RemoveAt(1) + Do Target.Insert(Links.GetAt(LinksIndex)) + Set LinksIndex = LinksIndex + 1 } - ElseIf (Rechts.Count() > 0) + ElseIf (Rechts.Count() > (RechtsIndex-1)) { - Do Target.Insert(Rechts.GetAt(1)) - Do Rechts.RemoveAt(1) + Do Target.Insert(Rechts.GetAt(RechtsIndex)) + Set RechtsIndex = RechtsIndex + 1 } } Quit Target