'排序选择集 Function Sort(SSet As AcadSelectionSet) Dim i As Variant Dim tmp As AcadEntity Dim counter As Variant
counter = SSet.Count - 1 i = 0 nextLoop: While (i < counter) If SSet(i).ObjectID > SSet(i + 1).ObjectID Then tmp = SSet(i) SSet(i) = SSet(i + 1) SSet(i + 1) = tmp i = 0 GoTo nextLoop End If i = i + 1 Wend End Function