<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Sort an array of text objects Asc by their X and Y insertion point values in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680020#M33429</link>
    <description>example of individual text objects on screen&lt;BR /&gt;
&lt;BR /&gt;
1    2    3&lt;BR /&gt;
4    5    6&lt;BR /&gt;
7    8    9&lt;BR /&gt;
&lt;BR /&gt;
User selects objects&lt;BR /&gt;
(objects are place into a selection set, then object in selection set are &lt;BR /&gt;
placed into an array)&lt;BR /&gt;
&lt;BR /&gt;
array order might look like this:&lt;BR /&gt;
&lt;BR /&gt;
2,4,7,8,0,1,5,3,6,9&lt;BR /&gt;
&lt;BR /&gt;
how do I sort the array by the text objects X,Y insertionpoint values:&lt;BR /&gt;
&lt;BR /&gt;
1,4,7,2,5,8,3,6,9 (outcome desired)&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks</description>
    <pubDate>Mon, 19 Jun 2006 19:35:15 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2006-06-19T19:35:15Z</dc:date>
    <item>
      <title>Sort an array of text objects Asc by their X and Y insertion point values</title>
      <link>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680020#M33429</link>
      <description>example of individual text objects on screen&lt;BR /&gt;
&lt;BR /&gt;
1    2    3&lt;BR /&gt;
4    5    6&lt;BR /&gt;
7    8    9&lt;BR /&gt;
&lt;BR /&gt;
User selects objects&lt;BR /&gt;
(objects are place into a selection set, then object in selection set are &lt;BR /&gt;
placed into an array)&lt;BR /&gt;
&lt;BR /&gt;
array order might look like this:&lt;BR /&gt;
&lt;BR /&gt;
2,4,7,8,0,1,5,3,6,9&lt;BR /&gt;
&lt;BR /&gt;
how do I sort the array by the text objects X,Y insertionpoint values:&lt;BR /&gt;
&lt;BR /&gt;
1,4,7,2,5,8,3,6,9 (outcome desired)&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks</description>
      <pubDate>Mon, 19 Jun 2006 19:35:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680020#M33429</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-19T19:35:15Z</dc:date>
    </item>
    <item>
      <title>Re: Sort an array of text objects Asc by their X and Y insertion point values</title>
      <link>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680021#M33430</link>
      <description>Sort the objects by the Y coordinates using any sort algorithm then sort them by the X coordinates using any stable sort algorithm.</description>
      <pubDate>Tue, 20 Jun 2006 13:12:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680021#M33430</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-20T13:12:52Z</dc:date>
    </item>
    <item>
      <title>Re: Sort an array of text objects Asc by their X and Y insertion point  values</title>
      <link>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680022#M33431</link>
      <description>Yup, looks good on paper. I haven't figured out how to create/use the sort &lt;BR /&gt;
algorithms yet.&lt;BR /&gt;
I did find a good site with many Sorting algorithms here: &lt;BR /&gt;
http://www.xtremevbtalk.com/showthread.php?t=78889&lt;BR /&gt;
These might help anyone in the future researching sorting.&lt;BR /&gt;
Dan&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;FANTUM&gt; wrote in message news:5211988@discussion.autodesk.com...&lt;BR /&gt;
Sort the objects by the Y coordinates using any sort algorithm then sort &lt;BR /&gt;
them by the X coordinates using any stable sort algorithm.&lt;/FANTUM&gt;</description>
      <pubDate>Tue, 20 Jun 2006 15:32:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680022#M33431</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-20T15:32:50Z</dc:date>
    </item>
    <item>
      <title>Re: Sort an array of text objects Asc by their X and Y insertion point  values</title>
      <link>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680023#M33432</link>
      <description>Do you need to sort the TextObjects or only the TextString.?How are you planing to sort them, X left or right and Y up or down? If possible what are you trying to accomplish?</description>
      <pubDate>Tue, 20 Jun 2006 20:10:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680023#M33432</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-20T20:10:52Z</dc:date>
    </item>
    <item>
      <title>Re: Sort an array of text objects Asc by their X and Y insertion point  values</title>
      <link>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680024#M33433</link>
      <description>Not sure how to clarify more, I will try.&lt;BR /&gt;
&lt;BR /&gt;
I need to sort Text Object in the following order:&lt;BR /&gt;
Text X coordinate Ascending&lt;BR /&gt;
then sort Text by Y coordinate Descending&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
start:&lt;BR /&gt;
1    2    3&lt;BR /&gt;
4    5    6&lt;BR /&gt;
7    8    9&lt;BR /&gt;
&lt;BR /&gt;
SSet order: 2,4,7,8,0,1,5,3,6,9&lt;BR /&gt;
Sorted order:1,4,7,2,5,8,3,6,9&lt;BR /&gt;
&lt;BR /&gt;
I just want the order to look like it reads. Text Top to bottom, then left &lt;BR /&gt;
to right.&lt;BR /&gt;
&lt;BR /&gt;
Thanks again,&lt;BR /&gt;
Dan&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
&lt;HJOHN&gt; wrote in message news:5212822@discussion.autodesk.com...&lt;BR /&gt;
Do you need to sort the TextObjects or only the TextString.?How are you &lt;BR /&gt;
planing to sort them, X left or right and Y up or down? If possible what are &lt;BR /&gt;
you trying to accomplish?&lt;/HJOHN&gt;</description>
      <pubDate>Tue, 20 Jun 2006 20:54:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680024#M33433</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-20T20:54:21Z</dc:date>
    </item>
    <item>
      <title>Re: Sort an array of text objects Asc by their X and Y insertion point  values</title>
      <link>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680025#M33434</link>
      <description>[code]&lt;BR /&gt;
 Sub Stub()&lt;BR /&gt;
  Dim SS As AcadSelectionSet&lt;BR /&gt;
  Dim filType(0) As Integer&lt;BR /&gt;
  Dim filData(0)&lt;BR /&gt;
  'filter data for TEXT&lt;BR /&gt;
  filType(0) = 0&lt;BR /&gt;
  filData(0) = "TEXT"&lt;BR /&gt;
&lt;BR /&gt;
  Set SS = SSAdd("test")&lt;BR /&gt;
  SS.SelectOnScreen filType, filData&lt;BR /&gt;
&lt;BR /&gt;
  Dim coll As New Collection&lt;BR /&gt;
  Dim min, max&lt;BR /&gt;
  Dim ent As AcadEntity&lt;BR /&gt;
  Dim i As Integer&lt;BR /&gt;
  'Iterate SS and add X of lower bound box point&lt;BR /&gt;
  'as collection item and handle of entity as key.&lt;BR /&gt;
  For i = 0 To SS.Count - 1&lt;BR /&gt;
    Set ent = SS(i)&lt;BR /&gt;
    ent.GetBoundingBox min, max&lt;BR /&gt;
    coll.Add min(0), ent.Handle&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  'call sort method by Christian d'Heureuse (www.source-code.biz)&lt;BR /&gt;
  'something lighter will do(bubblesort), this is first I found.&lt;BR /&gt;
  Set coll = SortCollection(coll)&lt;BR /&gt;
&lt;BR /&gt;
  'do the same for min Y points...&lt;BR /&gt;
&lt;BR /&gt;
  Call SSRemove("test")&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Function SSAdd(inName As String) As AcadSelectionSet&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  With ThisDrawing&lt;BR /&gt;
    .SelectionSets(inName).Delete&lt;BR /&gt;
    Set SSAdd = .SelectionSets.Add(inName)&lt;BR /&gt;
  End With&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Sub SSRemove(inName As String)&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  ThisDrawing.SelectionSets(inName).Delete&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
' This routine uses the "heap sort" algorithm to sort a VB collection.&lt;BR /&gt;
' It returns the sorted collection.&lt;BR /&gt;
' Author: Christian d'Heureuse (www.source-code.biz)&lt;BR /&gt;
Public Function SortCollection(ByVal c As Collection) As Collection&lt;BR /&gt;
   Dim n As Long: n = c.Count&lt;BR /&gt;
   If n = 0 Then Set SortCollection = New Collection: Exit Function&lt;BR /&gt;
   ReDim Index(0 To n - 1) As Long                    ' allocate index array&lt;BR /&gt;
   Dim i As Long, m As Long&lt;BR /&gt;
   For i = 0 To n - 1: Index(i) = i + 1: Next         ' fill index array&lt;BR /&gt;
   For i = n \ 2 - 1 To 0 Step -1                     ' generate ordered &lt;BR /&gt;
heap&lt;BR /&gt;
      Heapify c, Index, i, n&lt;BR /&gt;
      Next&lt;BR /&gt;
   For m = n To 2 Step -1                             ' sort the index array&lt;BR /&gt;
      Exchange Index, 0, m - 1                        ' move highest element &lt;BR /&gt;
to top&lt;BR /&gt;
      Heapify c, Index, 0, m - 1&lt;BR /&gt;
      Next&lt;BR /&gt;
   Dim c2 As New Collection&lt;BR /&gt;
   For i = 0 To n - 1: c2.Add c.Item(Index(i)): Next  ' fill output &lt;BR /&gt;
collection&lt;BR /&gt;
   Set SortCollection = c2&lt;BR /&gt;
   End Function&lt;BR /&gt;
&lt;BR /&gt;
Private Sub Heapify(ByVal c As Collection, Index() As Long, ByVal i1 As &lt;BR /&gt;
Long, ByVal n As Long)&lt;BR /&gt;
   ' Heap order rule: a&lt;I&gt; &amp;gt;= a[2*i+1] and a&lt;I&gt; &amp;gt;= a[2*i+2]&lt;BR /&gt;
   Dim nDiv2 As Long: nDiv2 = n \ 2&lt;BR /&gt;
   Dim i As Long: i = i1&lt;BR /&gt;
   Do While i &amp;lt; nDiv2&lt;BR /&gt;
      Dim k As Long: k = 2 * i + 1&lt;BR /&gt;
      If k + 1 &amp;lt; n Then&lt;BR /&gt;
         If c.Item(Index(k)) &amp;lt; c.Item(Index(k + 1)) Then k = k + 1&lt;BR /&gt;
         End If&lt;BR /&gt;
      If c.Item(Index(i)) &amp;gt;= c.Item(Index(k)) Then Exit Do&lt;BR /&gt;
      Exchange Index, i, k&lt;BR /&gt;
      i = k&lt;BR /&gt;
      Loop&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Private Sub Exchange(Index() As Long, ByVal i As Long, ByVal j As Long)&lt;BR /&gt;
   Dim Temp As Long: Temp = Index(i)&lt;BR /&gt;
   Index(i) = Index(j)&lt;BR /&gt;
   Index(j) = Temp&lt;BR /&gt;
End Sub&lt;BR /&gt;
[/code]&lt;BR /&gt;
&lt;BR /&gt;
"Dan" &lt;DANDERSON&gt; wrote in message &lt;BR /&gt;
news:5212919@discussion.autodesk.com...&lt;BR /&gt;
Not sure how to clarify more, I will try.&lt;BR /&gt;
&lt;BR /&gt;
I need to sort Text Object in the following order:&lt;BR /&gt;
Text X coordinate Ascending&lt;BR /&gt;
then sort Text by Y coordinate Descending&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
start:&lt;BR /&gt;
1    2    3&lt;BR /&gt;
4    5    6&lt;BR /&gt;
7    8    9&lt;BR /&gt;
&lt;BR /&gt;
SSet order: 2,4,7,8,0,1,5,3,6,9&lt;BR /&gt;
Sorted order:1,4,7,2,5,8,3,6,9&lt;BR /&gt;
&lt;BR /&gt;
I just want the order to look like it reads. Text Top to bottom, then left&lt;BR /&gt;
to right.&lt;BR /&gt;
&lt;BR /&gt;
Thanks again,&lt;BR /&gt;
Dan&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
&lt;HJOHN&gt; wrote in message news:5212822@discussion.autodesk.com...&lt;BR /&gt;
Do you need to sort the TextObjects or only the TextString.?How are you&lt;BR /&gt;
planing to sort them, X left or right and Y up or down? If possible what are&lt;BR /&gt;
you trying to accomplish?&lt;/HJOHN&gt;&lt;/DANDERSON&gt;&lt;/I&gt;&lt;/I&gt;</description>
      <pubDate>Tue, 20 Jun 2006 21:33:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680025#M33434</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-20T21:33:17Z</dc:date>
    </item>
    <item>
      <title>Re: Sort an array of text objects Asc by their X and Y insertion point  values</title>
      <link>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680026#M33435</link>
      <description>you have a few lines with word wrap in there...&lt;BR /&gt;
"Paul Richardson" &lt;PRICHARDSONATADELPHIA.NET&gt; wrote in message &lt;BR /&gt;
news:5212951@discussion.autodesk.com...&lt;BR /&gt;
[code]&lt;BR /&gt;
 Sub Stub()&lt;BR /&gt;
  Dim SS As AcadSelectionSet&lt;BR /&gt;
  Dim filType(0) As Integer&lt;BR /&gt;
  Dim filData(0)&lt;BR /&gt;
  'filter data for TEXT&lt;BR /&gt;
  filType(0) = 0&lt;BR /&gt;
  filData(0) = "TEXT"&lt;BR /&gt;
&lt;BR /&gt;
  Set SS = SSAdd("test")&lt;BR /&gt;
  SS.SelectOnScreen filType, filData&lt;BR /&gt;
&lt;BR /&gt;
  Dim coll As New Collection&lt;BR /&gt;
  Dim min, max&lt;BR /&gt;
  Dim ent As AcadEntity&lt;BR /&gt;
  Dim i As Integer&lt;BR /&gt;
  'Iterate SS and add X of lower bound box point&lt;BR /&gt;
  'as collection item and handle of entity as key.&lt;BR /&gt;
  For i = 0 To SS.Count - 1&lt;BR /&gt;
    Set ent = SS(i)&lt;BR /&gt;
    ent.GetBoundingBox min, max&lt;BR /&gt;
    coll.Add min(0), ent.Handle&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  'call sort method by Christian d'Heureuse (www.source-code.biz)&lt;BR /&gt;
  'something lighter will do(bubblesort), this is first I found.&lt;BR /&gt;
  Set coll = SortCollection(coll)&lt;BR /&gt;
&lt;BR /&gt;
  'do the same for min Y points...&lt;BR /&gt;
&lt;BR /&gt;
  Call SSRemove("test")&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Function SSAdd(inName As String) As AcadSelectionSet&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  With ThisDrawing&lt;BR /&gt;
    .SelectionSets(inName).Delete&lt;BR /&gt;
    Set SSAdd = .SelectionSets.Add(inName)&lt;BR /&gt;
  End With&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Sub SSRemove(inName As String)&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  ThisDrawing.SelectionSets(inName).Delete&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
' This routine uses the "heap sort" algorithm to sort a VB collection.&lt;BR /&gt;
' It returns the sorted collection.&lt;BR /&gt;
' Author: Christian d'Heureuse (www.source-code.biz)&lt;BR /&gt;
Public Function SortCollection(ByVal c As Collection) As Collection&lt;BR /&gt;
   Dim n As Long: n = c.Count&lt;BR /&gt;
   If n = 0 Then Set SortCollection = New Collection: Exit Function&lt;BR /&gt;
   ReDim Index(0 To n - 1) As Long                    ' allocate index array&lt;BR /&gt;
   Dim i As Long, m As Long&lt;BR /&gt;
   For i = 0 To n - 1: Index(i) = i + 1: Next         ' fill index array&lt;BR /&gt;
   For i = n \ 2 - 1 To 0 Step -1                     ' generate ordered&lt;BR /&gt;
heap&lt;BR /&gt;
      Heapify c, Index, i, n&lt;BR /&gt;
      Next&lt;BR /&gt;
   For m = n To 2 Step -1                             ' sort the index array&lt;BR /&gt;
      Exchange Index, 0, m - 1                        ' move highest element&lt;BR /&gt;
to top&lt;BR /&gt;
      Heapify c, Index, 0, m - 1&lt;BR /&gt;
      Next&lt;BR /&gt;
   Dim c2 As New Collection&lt;BR /&gt;
   For i = 0 To n - 1: c2.Add c.Item(Index(i)): Next  ' fill output&lt;BR /&gt;
collection&lt;BR /&gt;
   Set SortCollection = c2&lt;BR /&gt;
   End Function&lt;BR /&gt;
&lt;BR /&gt;
Private Sub Heapify(ByVal c As Collection, Index() As Long, ByVal i1 As&lt;BR /&gt;
Long, ByVal n As Long)&lt;BR /&gt;
   ' Heap order rule: a&lt;I&gt; &amp;gt;= a[2*i+1] and a&lt;I&gt; &amp;gt;= a[2*i+2]&lt;BR /&gt;
   Dim nDiv2 As Long: nDiv2 = n \ 2&lt;BR /&gt;
   Dim i As Long: i = i1&lt;BR /&gt;
   Do While i &amp;lt; nDiv2&lt;BR /&gt;
      Dim k As Long: k = 2 * i + 1&lt;BR /&gt;
      If k + 1 &amp;lt; n Then&lt;BR /&gt;
         If c.Item(Index(k)) &amp;lt; c.Item(Index(k + 1)) Then k = k + 1&lt;BR /&gt;
         End If&lt;BR /&gt;
      If c.Item(Index(i)) &amp;gt;= c.Item(Index(k)) Then Exit Do&lt;BR /&gt;
      Exchange Index, i, k&lt;BR /&gt;
      i = k&lt;BR /&gt;
      Loop&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Private Sub Exchange(Index() As Long, ByVal i As Long, ByVal j As Long)&lt;BR /&gt;
   Dim Temp As Long: Temp = Index(i)&lt;BR /&gt;
   Index(i) = Index(j)&lt;BR /&gt;
   Index(j) = Temp&lt;BR /&gt;
End Sub&lt;BR /&gt;
[/code]&lt;BR /&gt;
&lt;BR /&gt;
"Dan" &lt;DANDERSON&gt; wrote in message&lt;BR /&gt;
news:5212919@discussion.autodesk.com...&lt;BR /&gt;
Not sure how to clarify more, I will try.&lt;BR /&gt;
&lt;BR /&gt;
I need to sort Text Object in the following order:&lt;BR /&gt;
Text X coordinate Ascending&lt;BR /&gt;
then sort Text by Y coordinate Descending&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
start:&lt;BR /&gt;
1    2    3&lt;BR /&gt;
4    5    6&lt;BR /&gt;
7    8    9&lt;BR /&gt;
&lt;BR /&gt;
SSet order: 2,4,7,8,0,1,5,3,6,9&lt;BR /&gt;
Sorted order:1,4,7,2,5,8,3,6,9&lt;BR /&gt;
&lt;BR /&gt;
I just want the order to look like it reads. Text Top to bottom, then left&lt;BR /&gt;
to right.&lt;BR /&gt;
&lt;BR /&gt;
Thanks again,&lt;BR /&gt;
Dan&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
&lt;HJOHN&gt; wrote in message news:5212822@discussion.autodesk.com...&lt;BR /&gt;
Do you need to sort the TextObjects or only the TextString.?How are you&lt;BR /&gt;
planing to sort them, X left or right and Y up or down? If possible what are&lt;BR /&gt;
you trying to accomplish?&lt;/HJOHN&gt;&lt;/DANDERSON&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRICHARDSONATADELPHIA.NET&gt;</description>
      <pubDate>Tue, 20 Jun 2006 21:40:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680026#M33435</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-20T21:40:29Z</dc:date>
    </item>
    <item>
      <title>Re: Sort an array of text objects Asc by their X and Y insertion point  values</title>
      <link>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680027#M33436</link>
      <description>Wow, this is complex! I am looking into it now...&lt;BR /&gt;
&lt;BR /&gt;
"Paul Richardson" &lt;PRICHARDSONATADELPHIA.NET&gt; wrote in message &lt;BR /&gt;
news:5212954@discussion.autodesk.com...&lt;BR /&gt;
you have a few lines with word wrap in there...&lt;BR /&gt;
"Paul Richardson" &lt;PRICHARDSONATADELPHIA.NET&gt; wrote in message&lt;BR /&gt;
news:5212951@discussion.autodesk.com...&lt;BR /&gt;
[code]&lt;BR /&gt;
 Sub Stub()&lt;BR /&gt;
  Dim SS As AcadSelectionSet&lt;BR /&gt;
  Dim filType(0) As Integer&lt;BR /&gt;
  Dim filData(0)&lt;BR /&gt;
  'filter data for TEXT&lt;BR /&gt;
  filType(0) = 0&lt;BR /&gt;
  filData(0) = "TEXT"&lt;BR /&gt;
&lt;BR /&gt;
  Set SS = SSAdd("test")&lt;BR /&gt;
  SS.SelectOnScreen filType, filData&lt;BR /&gt;
&lt;BR /&gt;
  Dim coll As New Collection&lt;BR /&gt;
  Dim min, max&lt;BR /&gt;
  Dim ent As AcadEntity&lt;BR /&gt;
  Dim i As Integer&lt;BR /&gt;
  'Iterate SS and add X of lower bound box point&lt;BR /&gt;
  'as collection item and handle of entity as key.&lt;BR /&gt;
  For i = 0 To SS.Count - 1&lt;BR /&gt;
    Set ent = SS(i)&lt;BR /&gt;
    ent.GetBoundingBox min, max&lt;BR /&gt;
    coll.Add min(0), ent.Handle&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  'call sort method by Christian d'Heureuse (www.source-code.biz)&lt;BR /&gt;
  'something lighter will do(bubblesort), this is first I found.&lt;BR /&gt;
  Set coll = SortCollection(coll)&lt;BR /&gt;
&lt;BR /&gt;
  'do the same for min Y points...&lt;BR /&gt;
&lt;BR /&gt;
  Call SSRemove("test")&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Function SSAdd(inName As String) As AcadSelectionSet&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  With ThisDrawing&lt;BR /&gt;
    .SelectionSets(inName).Delete&lt;BR /&gt;
    Set SSAdd = .SelectionSets.Add(inName)&lt;BR /&gt;
  End With&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Sub SSRemove(inName As String)&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  ThisDrawing.SelectionSets(inName).Delete&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
' This routine uses the "heap sort" algorithm to sort a VB collection.&lt;BR /&gt;
' It returns the sorted collection.&lt;BR /&gt;
' Author: Christian d'Heureuse (www.source-code.biz)&lt;BR /&gt;
Public Function SortCollection(ByVal c As Collection) As Collection&lt;BR /&gt;
   Dim n As Long: n = c.Count&lt;BR /&gt;
   If n = 0 Then Set SortCollection = New Collection: Exit Function&lt;BR /&gt;
   ReDim Index(0 To n - 1) As Long                    ' allocate index array&lt;BR /&gt;
   Dim i As Long, m As Long&lt;BR /&gt;
   For i = 0 To n - 1: Index(i) = i + 1: Next         ' fill index array&lt;BR /&gt;
   For i = n \ 2 - 1 To 0 Step -1                     ' generate ordered&lt;BR /&gt;
heap&lt;BR /&gt;
      Heapify c, Index, i, n&lt;BR /&gt;
      Next&lt;BR /&gt;
   For m = n To 2 Step -1                             ' sort the index array&lt;BR /&gt;
      Exchange Index, 0, m - 1                        ' move highest element&lt;BR /&gt;
to top&lt;BR /&gt;
      Heapify c, Index, 0, m - 1&lt;BR /&gt;
      Next&lt;BR /&gt;
   Dim c2 As New Collection&lt;BR /&gt;
   For i = 0 To n - 1: c2.Add c.Item(Index(i)): Next  ' fill output&lt;BR /&gt;
collection&lt;BR /&gt;
   Set SortCollection = c2&lt;BR /&gt;
   End Function&lt;BR /&gt;
&lt;BR /&gt;
Private Sub Heapify(ByVal c As Collection, Index() As Long, ByVal i1 As&lt;BR /&gt;
Long, ByVal n As Long)&lt;BR /&gt;
   ' Heap order rule: a&lt;I&gt; &amp;gt;= a[2*i+1] and a&lt;I&gt; &amp;gt;= a[2*i+2]&lt;BR /&gt;
   Dim nDiv2 As Long: nDiv2 = n \ 2&lt;BR /&gt;
   Dim i As Long: i = i1&lt;BR /&gt;
   Do While i &amp;lt; nDiv2&lt;BR /&gt;
      Dim k As Long: k = 2 * i + 1&lt;BR /&gt;
      If k + 1 &amp;lt; n Then&lt;BR /&gt;
         If c.Item(Index(k)) &amp;lt; c.Item(Index(k + 1)) Then k = k + 1&lt;BR /&gt;
         End If&lt;BR /&gt;
      If c.Item(Index(i)) &amp;gt;= c.Item(Index(k)) Then Exit Do&lt;BR /&gt;
      Exchange Index, i, k&lt;BR /&gt;
      i = k&lt;BR /&gt;
      Loop&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Private Sub Exchange(Index() As Long, ByVal i As Long, ByVal j As Long)&lt;BR /&gt;
   Dim Temp As Long: Temp = Index(i)&lt;BR /&gt;
   Index(i) = Index(j)&lt;BR /&gt;
   Index(j) = Temp&lt;BR /&gt;
End Sub&lt;BR /&gt;
[/code]&lt;BR /&gt;
&lt;BR /&gt;
"Dan" &lt;DANDERSON&gt; wrote in message&lt;BR /&gt;
news:5212919@discussion.autodesk.com...&lt;BR /&gt;
Not sure how to clarify more, I will try.&lt;BR /&gt;
&lt;BR /&gt;
I need to sort Text Object in the following order:&lt;BR /&gt;
Text X coordinate Ascending&lt;BR /&gt;
then sort Text by Y coordinate Descending&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
start:&lt;BR /&gt;
1    2    3&lt;BR /&gt;
4    5    6&lt;BR /&gt;
7    8    9&lt;BR /&gt;
&lt;BR /&gt;
SSet order: 2,4,7,8,0,1,5,3,6,9&lt;BR /&gt;
Sorted order:1,4,7,2,5,8,3,6,9&lt;BR /&gt;
&lt;BR /&gt;
I just want the order to look like it reads. Text Top to bottom, then left&lt;BR /&gt;
to right.&lt;BR /&gt;
&lt;BR /&gt;
Thanks again,&lt;BR /&gt;
Dan&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
&lt;HJOHN&gt; wrote in message news:5212822@discussion.autodesk.com...&lt;BR /&gt;
Do you need to sort the TextObjects or only the TextString.?How are you&lt;BR /&gt;
planing to sort them, X left or right and Y up or down? If possible what are&lt;BR /&gt;
you trying to accomplish?&lt;/HJOHN&gt;&lt;/DANDERSON&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRICHARDSONATADELPHIA.NET&gt;&lt;/PRICHARDSONATADELPHIA.NET&gt;</description>
      <pubDate>Tue, 20 Jun 2006 22:14:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680027#M33436</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-20T22:14:08Z</dc:date>
    </item>
    <item>
      <title>Re: Sort an array of text objects Asc by their X and Y insertion point  values</title>
      <link>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680028#M33437</link>
      <description>This is what I have so far.  I am attaching a sample drawing to help make my &lt;BR /&gt;
intentions clear. Thank you all so much.  This is indeed more challenging &lt;BR /&gt;
than I originally thought.&lt;BR /&gt;
&lt;BR /&gt;
[code]&lt;BR /&gt;
Option Explicit&lt;BR /&gt;
Sub FieldsToTableFinal()&lt;BR /&gt;
Dim oSsets As AcadSelectionSets&lt;BR /&gt;
Dim oSset As AcadSelectionSet&lt;BR /&gt;
Dim oTable As AcadTable&lt;BR /&gt;
Dim oText As AcadText&lt;BR /&gt;
Dim j, k, l, m As Long&lt;BR /&gt;
Dim i, n As Integer&lt;BR /&gt;
Dim ftype(0) As Integer&lt;BR /&gt;
Dim fData(0) As Variant&lt;BR /&gt;
Dim insPt As Variant&lt;BR /&gt;
Dim tmpStr As String&lt;BR /&gt;
Dim basePnt As Variant&lt;BR /&gt;
Dim celltxtchk As String&lt;BR /&gt;
Dim oMText As AcadMText&lt;BR /&gt;
Dim SSetSort As Variant&lt;BR /&gt;
&lt;BR /&gt;
    ftype(0) = 0: fData(0) = "TEXT"&lt;BR /&gt;
    On Error Resume Next&lt;BR /&gt;
    ThisDrawing.SelectionSets.Item("FieldsToTable").Delete&lt;BR /&gt;
    Set oSset = ThisDrawing.SelectionSets.Add("FieldsToTable")&lt;BR /&gt;
    On Error GoTo ErrMsg&lt;BR /&gt;
    oSset.SelectOnScreen 'I need to figure out filtering for moth Text &amp;amp; &lt;BR /&gt;
mText&lt;BR /&gt;
&lt;BR /&gt;
    'I am stuck on this section&lt;BR /&gt;
    For i = 0 To oSset.Count - 1&lt;BR /&gt;
        Set SSetSort(i) = oSset.Item(i)&lt;BR /&gt;
        '&lt;BR /&gt;
        'SORT Code here?&lt;BR /&gt;
        '&lt;BR /&gt;
        'I need to figure out how to resort this array, and place the &lt;BR /&gt;
correct order&lt;BR /&gt;
        'back into a SS to use&lt;BR /&gt;
    Next&lt;BR /&gt;
&lt;BR /&gt;
    i = oSset.Count&lt;BR /&gt;
    ThisDrawing.Utility.GetEntity oTable, basePnt, "Select Table to &lt;BR /&gt;
fill-out:"&lt;BR /&gt;
    k = oTable.Columns&lt;BR /&gt;
    If k &amp;lt;&amp;gt; 2 And k &amp;lt;&amp;gt; 5 Then&lt;BR /&gt;
        Exit Sub&lt;BR /&gt;
    End If&lt;BR /&gt;
    j = i \ k&lt;BR /&gt;
    l = 0&lt;BR /&gt;
    n = 0&lt;BR /&gt;
    For l = 0 To k - 1&lt;BR /&gt;
        For m = 3 To j + 2&lt;BR /&gt;
            celltxtchk = oSset.Item(n).ObjectName&lt;BR /&gt;
            If celltxtchk = "AcDbMText" Then&lt;BR /&gt;
                Set oMText = oSset.Item(n)&lt;BR /&gt;
                MsgBox oMText.TextString&lt;BR /&gt;
                MsgBox oMText.InsertionPoint(1)&lt;BR /&gt;
                tmpStr = CStr(oMText.ObjectID)&lt;BR /&gt;
            End If&lt;BR /&gt;
            If celltxtchk = "AcDbText" Then&lt;BR /&gt;
                Set oText = oSset.Item(n)&lt;BR /&gt;
                MsgBox oText.TextString&lt;BR /&gt;
                MsgBox oText.InsertionPoint(1)&lt;BR /&gt;
                tmpStr = CStr(oText.ObjectID)&lt;BR /&gt;
            End If&lt;BR /&gt;
            tmpStr = "%&amp;lt;\AcObjProp Object(%&amp;lt;\_ObjId " &amp;amp; tmpStr &amp;amp; _&lt;BR /&gt;
            "&amp;gt;%).TextString \f " &amp;amp; "" &amp;amp; "%bl2" &amp;amp; "" &amp;amp; "&amp;gt;%"&lt;BR /&gt;
            oTable.SetText m, l, tmpStr&lt;BR /&gt;
            n = n + 1&lt;BR /&gt;
            oTable.Update&lt;BR /&gt;
        Next&lt;BR /&gt;
    Next&lt;BR /&gt;
&lt;BR /&gt;
    oSset.Clear&lt;BR /&gt;
    oSset.Delete&lt;BR /&gt;
    Set oSset = Nothing&lt;BR /&gt;
    Set oSsets = Nothing&lt;BR /&gt;
    Set oTable = Nothing&lt;BR /&gt;
    Exit Sub&lt;BR /&gt;
&lt;BR /&gt;
ErrMsg:&lt;BR /&gt;
    MsgBox Err.Description&lt;BR /&gt;
&lt;BR /&gt;
 End Sub&lt;BR /&gt;
[/code]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Dan&lt;BR /&gt;
&lt;BR /&gt;
"Dan" &lt;DANDERSON&gt; wrote in message &lt;BR /&gt;
news:5212989@discussion.autodesk.com...&lt;BR /&gt;
Wow, this is complex! I am looking into it now...&lt;BR /&gt;
&lt;BR /&gt;
"Paul Richardson" &lt;PRICHARDSONATADELPHIA.NET&gt; wrote in message&lt;BR /&gt;
news:5212954@discussion.autodesk.com...&lt;BR /&gt;
you have a few lines with word wrap in there...&lt;BR /&gt;
"Paul Richardson" &lt;PRICHARDSONATADELPHIA.NET&gt; wrote in message&lt;BR /&gt;
news:5212951@discussion.autodesk.com...&lt;BR /&gt;
[code]&lt;BR /&gt;
 Sub Stub()&lt;BR /&gt;
  Dim SS As AcadSelectionSet&lt;BR /&gt;
  Dim filType(0) As Integer&lt;BR /&gt;
  Dim filData(0)&lt;BR /&gt;
  'filter data for TEXT&lt;BR /&gt;
  filType(0) = 0&lt;BR /&gt;
  filData(0) = "TEXT"&lt;BR /&gt;
&lt;BR /&gt;
  Set SS = SSAdd("test")&lt;BR /&gt;
  SS.SelectOnScreen filType, filData&lt;BR /&gt;
&lt;BR /&gt;
  Dim coll As New Collection&lt;BR /&gt;
  Dim min, max&lt;BR /&gt;
  Dim ent As AcadEntity&lt;BR /&gt;
  Dim i As Integer&lt;BR /&gt;
  'Iterate SS and add X of lower bound box point&lt;BR /&gt;
  'as collection item and handle of entity as key.&lt;BR /&gt;
  For i = 0 To SS.Count - 1&lt;BR /&gt;
    Set ent = SS(i)&lt;BR /&gt;
    ent.GetBoundingBox min, max&lt;BR /&gt;
    coll.Add min(0), ent.Handle&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  'call sort method by Christian d'Heureuse (www.source-code.biz)&lt;BR /&gt;
  'something lighter will do(bubblesort), this is first I found.&lt;BR /&gt;
  Set coll = SortCollection(coll)&lt;BR /&gt;
&lt;BR /&gt;
  'do the same for min Y points...&lt;BR /&gt;
&lt;BR /&gt;
  Call SSRemove("test")&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Function SSAdd(inName As String) As AcadSelectionSet&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  With ThisDrawing&lt;BR /&gt;
    .SelectionSets(inName).Delete&lt;BR /&gt;
    Set SSAdd = .SelectionSets.Add(inName)&lt;BR /&gt;
  End With&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Sub SSRemove(inName As String)&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  ThisDrawing.SelectionSets(inName).Delete&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
' This routine uses the "heap sort" algorithm to sort a VB collection.&lt;BR /&gt;
' It returns the sorted collection.&lt;BR /&gt;
' Author: Christian d'Heureuse (www.source-code.biz)&lt;BR /&gt;
Public Function SortCollection(ByVal c As Collection) As Collection&lt;BR /&gt;
   Dim n As Long: n = c.Count&lt;BR /&gt;
   If n = 0 Then Set SortCollection = New Collection: Exit Function&lt;BR /&gt;
   ReDim Index(0 To n - 1) As Long                    ' allocate index array&lt;BR /&gt;
   Dim i As Long, m As Long&lt;BR /&gt;
   For i = 0 To n - 1: Index(i) = i + 1: Next         ' fill index array&lt;BR /&gt;
   For i = n \ 2 - 1 To 0 Step -1                     ' generate ordered&lt;BR /&gt;
heap&lt;BR /&gt;
      Heapify c, Index, i, n&lt;BR /&gt;
      Next&lt;BR /&gt;
   For m = n To 2 Step -1                             ' sort the index array&lt;BR /&gt;
      Exchange Index, 0, m - 1                        ' move highest element&lt;BR /&gt;
to top&lt;BR /&gt;
      Heapify c, Index, 0, m - 1&lt;BR /&gt;
      Next&lt;BR /&gt;
   Dim c2 As New Collection&lt;BR /&gt;
   For i = 0 To n - 1: c2.Add c.Item(Index(i)): Next  ' fill output&lt;BR /&gt;
collection&lt;BR /&gt;
   Set SortCollection = c2&lt;BR /&gt;
   End Function&lt;BR /&gt;
&lt;BR /&gt;
Private Sub Heapify(ByVal c As Collection, Index() As Long, ByVal i1 As&lt;BR /&gt;
Long, ByVal n As Long)&lt;BR /&gt;
   ' Heap order rule: a&lt;I&gt; &amp;gt;= a[2*i+1] and a&lt;I&gt; &amp;gt;= a[2*i+2]&lt;BR /&gt;
   Dim nDiv2 As Long: nDiv2 = n \ 2&lt;BR /&gt;
   Dim i As Long: i = i1&lt;BR /&gt;
   Do While i &amp;lt; nDiv2&lt;BR /&gt;
      Dim k As Long: k = 2 * i + 1&lt;BR /&gt;
      If k + 1 &amp;lt; n Then&lt;BR /&gt;
         If c.Item(Index(k)) &amp;lt; c.Item(Index(k + 1)) Then k = k + 1&lt;BR /&gt;
         End If&lt;BR /&gt;
      If c.Item(Index(i)) &amp;gt;= c.Item(Index(k)) Then Exit Do&lt;BR /&gt;
      Exchange Index, i, k&lt;BR /&gt;
      i = k&lt;BR /&gt;
      Loop&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Private Sub Exchange(Index() As Long, ByVal i As Long, ByVal j As Long)&lt;BR /&gt;
   Dim Temp As Long: Temp = Index(i)&lt;BR /&gt;
   Index(i) = Index(j)&lt;BR /&gt;
   Index(j) = Temp&lt;BR /&gt;
End Sub&lt;BR /&gt;
[/code]&lt;BR /&gt;
&lt;BR /&gt;
"Dan" &lt;DANDERSON&gt; wrote in message&lt;BR /&gt;
news:5212919@discussion.autodesk.com...&lt;BR /&gt;
Not sure how to clarify more, I will try.&lt;BR /&gt;
&lt;BR /&gt;
I need to sort Text Object in the following order:&lt;BR /&gt;
Text X coordinate Ascending&lt;BR /&gt;
then sort Text by Y coordinate Descending&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
start:&lt;BR /&gt;
1    2    3&lt;BR /&gt;
4    5    6&lt;BR /&gt;
7    8    9&lt;BR /&gt;
&lt;BR /&gt;
SSet order: 2,4,7,8,0,1,5,3,6,9&lt;BR /&gt;
Sorted order:1,4,7,2,5,8,3,6,9&lt;BR /&gt;
&lt;BR /&gt;
I just want the order to look like it reads. Text Top to bottom, then left&lt;BR /&gt;
to right.&lt;BR /&gt;
&lt;BR /&gt;
Thanks again,&lt;BR /&gt;
Dan&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
&lt;HJOHN&gt; wrote in message news:5212822@discussion.autodesk.com...&lt;BR /&gt;
Do you need to sort the TextObjects or only the TextString.?How are you&lt;BR /&gt;
planing to sort them, X left or right and Y up or down? If possible what are&lt;BR /&gt;
you trying to accomplish?&lt;/HJOHN&gt;&lt;/DANDERSON&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRICHARDSONATADELPHIA.NET&gt;&lt;/PRICHARDSONATADELPHIA.NET&gt;&lt;/DANDERSON&gt;</description>
      <pubDate>Tue, 20 Jun 2006 22:23:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680028#M33437</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-20T22:23:24Z</dc:date>
    </item>
    <item>
      <title>Re: Sort an array of text objects Asc by their X and Y insertion point  values</title>
      <link>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680029#M33438</link>
      <description>a Dictionary will work better...I'll write it up hold on.&lt;BR /&gt;
"Dan" &lt;DANDERSON&gt; wrote in message &lt;BR /&gt;
news:5213035@discussion.autodesk.com...&lt;BR /&gt;
This is what I have so far.  I am attaching a sample drawing to help make my&lt;BR /&gt;
intentions clear. Thank you all so much.  This is indeed more challenging&lt;BR /&gt;
than I originally thought.&lt;BR /&gt;
&lt;BR /&gt;
[code]&lt;BR /&gt;
Option Explicit&lt;BR /&gt;
Sub FieldsToTableFinal()&lt;BR /&gt;
Dim oSsets As AcadSelectionSets&lt;BR /&gt;
Dim oSset As AcadSelectionSet&lt;BR /&gt;
Dim oTable As AcadTable&lt;BR /&gt;
Dim oText As AcadText&lt;BR /&gt;
Dim j, k, l, m As Long&lt;BR /&gt;
Dim i, n As Integer&lt;BR /&gt;
Dim ftype(0) As Integer&lt;BR /&gt;
Dim fData(0) As Variant&lt;BR /&gt;
Dim insPt As Variant&lt;BR /&gt;
Dim tmpStr As String&lt;BR /&gt;
Dim basePnt A&lt;BR /&gt;
s Variant&lt;BR /&gt;
Dim celltxtchk As String&lt;BR /&gt;
Dim oMText As AcadMText&lt;BR /&gt;
Dim SSetSort As Variant&lt;BR /&gt;
&lt;BR /&gt;
    ftype(0) = 0: fData(0) = "TEXT"&lt;BR /&gt;
    On Error Resume Next&lt;BR /&gt;
    ThisDrawing.SelectionSets.Item("FieldsToTable").Delete&lt;BR /&gt;
    Set oSset = ThisDrawing.SelectionSets.Add("FieldsToTable")&lt;BR /&gt;
    On Error GoTo ErrMsg&lt;BR /&gt;
    oSset.SelectOnScreen 'I need to figure out filtering for moth Text &amp;amp;&lt;BR /&gt;
mText&lt;BR /&gt;
&lt;BR /&gt;
    'I am stuck on this section&lt;BR /&gt;
    For i = 0 To oSset.Count - 1&lt;BR /&gt;
        Set SSetSort(i) = oSset.Item(i)&lt;BR /&gt;
&lt;BR /&gt;
    '&lt;BR /&gt;
        'SORT Code here?&lt;BR /&gt;
        '&lt;BR /&gt;
        'I need to figure out how to resort this array, and place the&lt;BR /&gt;
correct order&lt;BR /&gt;
        'back into a SS to use&lt;BR /&gt;
    Next&lt;BR /&gt;
&lt;BR /&gt;
    i = oSset.Count&lt;BR /&gt;
    ThisDrawing.Utility.GetEntity oTable, basePnt, "Select Table to&lt;BR /&gt;
fill-out:"&lt;BR /&gt;
    k = oTable.Columns&lt;BR /&gt;
    If k &amp;lt;&amp;gt; 2 And k &amp;lt;&amp;gt; 5 Then&lt;BR /&gt;
        Exit Sub&lt;BR /&gt;
    End If&lt;BR /&gt;
    j = i \ k&lt;BR /&gt;
    l = 0&lt;BR /&gt;
    n = 0&lt;BR /&gt;
    For l = 0 To k - 1&lt;BR /&gt;
        For m = 3 To j + 2&lt;BR /&gt;
            celltxtchk = oSset.Item(n)&lt;BR /&gt;
ObjectName&lt;BR /&gt;
            If celltxtchk = "AcDbMText" Then&lt;BR /&gt;
                Set oMText = oSset.Item(n)&lt;BR /&gt;
                MsgBox oMText.TextString&lt;BR /&gt;
                MsgBox oMText.InsertionPoint(1)&lt;BR /&gt;
                tmpStr = CStr(oMText.ObjectID)&lt;BR /&gt;
            End If&lt;BR /&gt;
            If celltxtchk = "AcDbText" Then&lt;BR /&gt;
                Set oText = oSset.Item(n)&lt;BR /&gt;
                MsgBox oText.TextString&lt;BR /&gt;
                MsgBox oText.InsertionPoint(1)&lt;BR /&gt;
                tmpStr = CStr(oText.ObjectID)&lt;BR /&gt;
&lt;BR /&gt;
End If&lt;BR /&gt;
            tmpStr = "%&amp;lt;\AcObjProp Object(%&amp;lt;\_ObjId " &amp;amp; tmpStr &amp;amp; _&lt;BR /&gt;
            "&amp;gt;%).TextString \f " &amp;amp; "" &amp;amp; "%bl2" &amp;amp; "" &amp;amp; "&amp;gt;%"&lt;BR /&gt;
            oTable.SetText m, l, tmpStr&lt;BR /&gt;
            n = n + 1&lt;BR /&gt;
            oTable.Update&lt;BR /&gt;
        Next&lt;BR /&gt;
    Next&lt;BR /&gt;
&lt;BR /&gt;
    oSset.Clear&lt;BR /&gt;
    oSset.Delete&lt;BR /&gt;
    Set oSset = Nothing&lt;BR /&gt;
    Set oSsets = Nothing&lt;BR /&gt;
    Set oTable = Nothing&lt;BR /&gt;
    Exit Sub&lt;BR /&gt;
&lt;BR /&gt;
ErrMsg:&lt;BR /&gt;
    MsgBox Err.Description&lt;BR /&gt;
&lt;BR /&gt;
 End Sub&lt;BR /&gt;
[/code]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Dan&lt;BR /&gt;
&lt;BR /&gt;
"Dan" &lt;DANDERSON&gt; wrote&lt;BR /&gt;
in message&lt;BR /&gt;
news:5212989@discussion.autodesk.com...&lt;BR /&gt;
Wow, this is complex! I am looking into it now...&lt;BR /&gt;
&lt;BR /&gt;
"Paul Richardson" &lt;PRICHARDSONATADELPHIA.NET&gt; wrote in message&lt;BR /&gt;
news:5212954@discussion.autodesk.com...&lt;BR /&gt;
you have a few lines with word wrap in there...&lt;BR /&gt;
"Paul Richardson" &lt;PRICHARDSONATADELPHIA.NET&gt; wrote in message&lt;BR /&gt;
news:5212951@discussion.autodesk.com...&lt;BR /&gt;
[code]&lt;BR /&gt;
 Sub Stub()&lt;BR /&gt;
  Dim SS As AcadSelectionSet&lt;BR /&gt;
  Dim filType(0) As Integer&lt;BR /&gt;
  Dim filData(0)&lt;BR /&gt;
  'filter data for TEXT&lt;BR /&gt;
  filType(0) = 0&lt;BR /&gt;
&lt;BR /&gt;
  filData(0) = "TEXT"&lt;BR /&gt;
&lt;BR /&gt;
  Set SS = SSAdd("test")&lt;BR /&gt;
  SS.SelectOnScreen filType, filData&lt;BR /&gt;
&lt;BR /&gt;
  Dim coll As New Collection&lt;BR /&gt;
  Dim min, max&lt;BR /&gt;
  Dim ent As AcadEntity&lt;BR /&gt;
  Dim i As Integer&lt;BR /&gt;
  'Iterate SS and add X of lower bound box point&lt;BR /&gt;
  'as collection item and handle of entity as key.&lt;BR /&gt;
  For i = 0 To SS.Count - 1&lt;BR /&gt;
    Set ent = SS(i)&lt;BR /&gt;
    ent.GetBoundingBox min, max&lt;BR /&gt;
    coll.Add min(0), ent.Handle&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  'call sort method by Christian d'Heureuse (www.source-code.biz)&lt;BR /&gt;
  'something lighter w&lt;BR /&gt;
ill do(bubblesort), this is first I found.&lt;BR /&gt;
  Set coll = SortCollection(coll)&lt;BR /&gt;
&lt;BR /&gt;
  'do the same for min Y points...&lt;BR /&gt;
&lt;BR /&gt;
  Call SSRemove("test")&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Function SSAdd(inName As String) As AcadSelectionSet&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  With ThisDrawing&lt;BR /&gt;
    .SelectionSets(inName).Delete&lt;BR /&gt;
    Set SSAdd = .SelectionSets.Add(inName)&lt;BR /&gt;
  End With&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Sub SSRemove(inName As String)&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  ThisDrawing.SelectionSets(inName).Delete&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
' This routine uses the "heap sor&lt;BR /&gt;
t" algorithm to sort a VB collection.&lt;BR /&gt;
' It returns the sorted collection.&lt;BR /&gt;
' Author: Christian d'Heureuse (www.source-code.biz)&lt;BR /&gt;
Public Function SortCollection(ByVal c As Collection) As Collection&lt;BR /&gt;
   Dim n As Long: n = c.Count&lt;BR /&gt;
   If n = 0 Then Set SortCollection = New Collection: Exit Function&lt;BR /&gt;
   ReDim Index(0 To n - 1) As Long                    ' allocate index array&lt;BR /&gt;
   Dim i As Long, m As Long&lt;BR /&gt;
   For i = 0 To n - 1: Index(i) = i + 1: Next         ' fill index array&lt;BR /&gt;
   For i = n&lt;BR /&gt;
 \ 2 - 1 To 0 Step -1                     ' generate ordered&lt;BR /&gt;
heap&lt;BR /&gt;
      Heapify c, Index, i, n&lt;BR /&gt;
      Next&lt;BR /&gt;
   For m = n To 2 Step -1                             ' sort the index array&lt;BR /&gt;
      Exchange Index, 0, m - 1                        ' move highest element&lt;BR /&gt;
to top&lt;BR /&gt;
      Heapify c, Index, 0, m - 1&lt;BR /&gt;
      Next&lt;BR /&gt;
   Dim c2 As New Collection&lt;BR /&gt;
   For i = 0 To n - 1: c2.Add c.Item(Index(i)): Next  ' fill output&lt;BR /&gt;
collection&lt;BR /&gt;
   Set SortCollection = c2&lt;BR /&gt;
   End Function&lt;BR /&gt;
&lt;BR /&gt;
Private Sub Heapify(B&lt;BR /&gt;
yVal c As Collection, Index() As Long, ByVal i1 As&lt;BR /&gt;
Long, ByVal n As Long)&lt;BR /&gt;
   ' Heap order rule: a&lt;I&gt; &amp;gt;= a[2*i+1] and a&lt;I&gt; &amp;gt;= a[2*i+2]&lt;BR /&gt;
   Dim nDiv2 As Long: nDiv2 = n \ 2&lt;BR /&gt;
   Dim i As Long: i = i1&lt;BR /&gt;
   Do While i &amp;lt; nDiv2&lt;BR /&gt;
      Dim k As Long: k = 2 * i + 1&lt;BR /&gt;
      If k + 1 &amp;lt; n Then&lt;BR /&gt;
         If c.Item(Index(k)) &amp;lt; c.Item(Index(k + 1)) Then k = k + 1&lt;BR /&gt;
         End If&lt;BR /&gt;
      If c.Item(Index(i)) &amp;gt;= c.Item(Index(k)) Then Exit Do&lt;BR /&gt;
      Exchange Index, i, k&lt;BR /&gt;
      i = k&lt;BR /&gt;
      Loop&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
P&lt;BR /&gt;
rivate Sub Exchange(Index() As Long, ByVal i As Long, ByVal j As Long)&lt;BR /&gt;
   Dim Temp As Long: Temp = Index(i)&lt;BR /&gt;
   Index(i) = Index(j)&lt;BR /&gt;
   Index(j) = Temp&lt;BR /&gt;
End Sub&lt;BR /&gt;
[/code]&lt;BR /&gt;
&lt;BR /&gt;
"Dan" &lt;DANDERSON&gt; wrote in message&lt;BR /&gt;
news:5212919@discussion.autodesk.com...&lt;BR /&gt;
Not sure how to clarify more, I will try.&lt;BR /&gt;
&lt;BR /&gt;
I need to sort Text Object in the following order:&lt;BR /&gt;
Text X coordinate Ascending&lt;BR /&gt;
then sort Text by Y coordinate Descending&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
start:&lt;BR /&gt;
1    2    3&lt;BR /&gt;
4    5    6&lt;BR /&gt;
7    8    9&lt;BR /&gt;
&lt;BR /&gt;
SSet or&lt;BR /&gt;
der: 2,4,7,8,0,1,5,3,6,9&lt;BR /&gt;
Sorted order:1,4,7,2,5,8,3,6,9&lt;BR /&gt;
&lt;BR /&gt;
I just want the order to look like it reads. Text Top to bottom, then left&lt;BR /&gt;
to right.&lt;BR /&gt;
&lt;BR /&gt;
Thanks again,&lt;BR /&gt;
Dan&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks&lt;BR /&gt;
&lt;HJOHN&gt; wrote in message news:5212822@discussion.autodesk.com...&lt;BR /&gt;
Do you need to sort the TextObjects or only the TextString.?How are you&lt;BR /&gt;
planing to sort them, X left or right and Y up or down? If possible what are&lt;BR /&gt;
you trying to accomplish?&lt;/HJOHN&gt;&lt;/DANDERSON&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRICHARDSONATADELPHIA.NET&gt;&lt;/PRICHARDSONATADELPHIA.NET&gt;&lt;/DANDERSON&gt;&lt;/DANDERSON&gt;</description>
      <pubDate>Tue, 20 Jun 2006 22:27:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680029#M33438</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-20T22:27:42Z</dc:date>
    </item>
    <item>
      <title>Re: Sort an array of text objects Asc by their X and Y insertion point  values</title>
      <link>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680030#M33439</link>
      <description>I really do not understand most of what is happening in the heap sort &lt;BR /&gt;
method, but I will learn it. I appreciate all the help.  This code is much &lt;BR /&gt;
more advanced than I have ever written.  I was hoping to learn some new &lt;BR /&gt;
tricks, but found a whole new area of coding I can explore.&lt;BR /&gt;
&lt;BR /&gt;
Thanks again,&lt;BR /&gt;
Dan</description>
      <pubDate>Tue, 20 Jun 2006 22:35:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680030#M33439</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-20T22:35:24Z</dc:date>
    </item>
    <item>
      <title>Re: Sort an array of text objects Asc by their X and Y insertion point  values</title>
      <link>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680031#M33440</link>
      <description>The nice thing is you don't have to know what is going in the sort&lt;BR /&gt;
methods, just that it returns a sorted something for now...&lt;BR /&gt;
&lt;BR /&gt;
That being said, here is code to add the x and y insertion coords to a 2d &lt;BR /&gt;
array,&lt;BR /&gt;
and then relate a sorted 2d array of insertion points back to entities in &lt;BR /&gt;
your selection set.&lt;BR /&gt;
&lt;BR /&gt;
You need a function to sort 2d arrays...google "Sort 2d coordinates" or such&lt;BR /&gt;
&lt;BR /&gt;
[code]&lt;BR /&gt;
 Sub Stub()&lt;BR /&gt;
  Dim SS As AcadSelectionSet&lt;BR /&gt;
  Dim filType(0) As Integer&lt;BR /&gt;
  Dim filData(0)&lt;BR /&gt;
  'filter data for TEXT&lt;BR /&gt;
  filType(0) = 0&lt;BR /&gt;
  filData(0) = "TEXT"&lt;BR /&gt;
&lt;BR /&gt;
  Set SS = SSAdd("test")&lt;BR /&gt;
  SS.SelectOnScreen filType, filData&lt;BR /&gt;
  'create 2d array (x,y) same size as your SS&lt;BR /&gt;
  ReDim coords(SS.Count - 1, 1)&lt;BR /&gt;
&lt;BR /&gt;
  Dim txtEnt As AcadText&lt;BR /&gt;
  Dim i As Integer&lt;BR /&gt;
&lt;BR /&gt;
  For i = 0 To SS.Count - 1&lt;BR /&gt;
    Set txtEnt = SS(i)&lt;BR /&gt;
    coords(i, 0) = txtEnt.InsertionPoint(0)&lt;BR /&gt;
    coords(i, 1) = txtEnt.InsertionPoint(1)&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  'now you have an array of 2d coordinates, do&lt;BR /&gt;
  'a google for a function that will sort 2d&lt;BR /&gt;
  'coordinate arrays.&lt;BR /&gt;
&lt;BR /&gt;
  Dim j As Integer&lt;BR /&gt;
 'relate sorted coords back to your SS ents&lt;BR /&gt;
 'doesn't consider duplicate insertion points&lt;BR /&gt;
  For i = LBound(coords) To UBound(coords)&lt;BR /&gt;
    For j = 0 To SS.Count - 1&lt;BR /&gt;
      Set txtEnt = SS(j)&lt;BR /&gt;
      If txtEnt.InsertionPoint(0) = coords(i, 0) And _&lt;BR /&gt;
          txtEnt.InsertionPoint(1) = coords(i, 1) Then&lt;BR /&gt;
          'add text value to your table&lt;BR /&gt;
          Exit For&lt;BR /&gt;
      End If&lt;BR /&gt;
    Next j&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  Call SSRemove("test")&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Function SSAdd(inName As String) As AcadSelectionSet&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  With ThisDrawing&lt;BR /&gt;
    .SelectionSets(inName).Delete&lt;BR /&gt;
    Set SSAdd = .SelectionSets.Add(inName)&lt;BR /&gt;
  End With&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Sub SSRemove(inName As String)&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  ThisDrawing.SelectionSets(inName).Delete&lt;BR /&gt;
End Sub&lt;BR /&gt;
[/code]&lt;BR /&gt;
&lt;BR /&gt;
"Dan" &lt;DANDERSON&gt; wrote in message &lt;BR /&gt;
news:5213024@discussion.autodesk.com...&lt;BR /&gt;
I really do not understand most of what is happening in the heap sort&lt;BR /&gt;
method, but I will learn it. I appreciate all the help.  This code is much&lt;BR /&gt;
more advanced than I have ever written.  I was hoping to learn some new&lt;BR /&gt;
tricks, but found a whole new area of coding I can explore.&lt;BR /&gt;
&lt;BR /&gt;
Thanks again,&lt;BR /&gt;
Dan&lt;/DANDERSON&gt;</description>
      <pubDate>Tue, 20 Jun 2006 23:55:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680031#M33440</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-20T23:55:35Z</dc:date>
    </item>
    <item>
      <title>Re: Sort an array of text objects Asc by their X and Y insertion point  values</title>
      <link>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680032#M33441</link>
      <description>Thank you so much. I will attemp to incorporate this new code and &lt;BR /&gt;
information into my routine.&lt;BR /&gt;
Thanks again for all your help.  When complete, this will save a tremendous &lt;BR /&gt;
amount of rework.&lt;BR /&gt;
&lt;BR /&gt;
Dan&lt;BR /&gt;
&lt;BR /&gt;
"Paul Richardson" &lt;PRICHARDSONATADELPHIA.NET&gt; wrote in message &lt;BR /&gt;
news:5213115@discussion.autodesk.com...&lt;BR /&gt;
The nice thing is you don't have to know what is going in the sort&lt;BR /&gt;
methods, just that it returns a sorted something for now...&lt;BR /&gt;
&lt;BR /&gt;
That being said, here is code to add the x and y insertion coords to a 2d&lt;BR /&gt;
array,&lt;BR /&gt;
and then relate a sorted 2d array of insertion points back to entities in&lt;BR /&gt;
your selection set.&lt;BR /&gt;
&lt;BR /&gt;
You need a function to sort 2d arrays...google "Sort 2d coordinates" or such&lt;BR /&gt;
&lt;BR /&gt;
[code]&lt;BR /&gt;
 Sub Stub()&lt;BR /&gt;
  Dim SS As AcadSelectionSet&lt;BR /&gt;
  Dim filType(0) As Integer&lt;BR /&gt;
  Dim filData(0)&lt;BR /&gt;
  'filter data for TEXT&lt;BR /&gt;
  filType(0) = 0&lt;BR /&gt;
  filData(0) = "TEXT"&lt;BR /&gt;
&lt;BR /&gt;
  Set SS = SSAdd("test")&lt;BR /&gt;
  SS.SelectOnScreen filType, filData&lt;BR /&gt;
  'create 2d array (x,y) same size as your SS&lt;BR /&gt;
  ReDim coords(SS.Count - 1, 1)&lt;BR /&gt;
&lt;BR /&gt;
  Dim txtEnt As AcadText&lt;BR /&gt;
  Dim i As Integer&lt;BR /&gt;
&lt;BR /&gt;
  For i = 0 To SS.Count - 1&lt;BR /&gt;
    Set txtEnt = SS(i)&lt;BR /&gt;
    coords(i, 0) = txtEnt.InsertionPoint(0)&lt;BR /&gt;
    coords(i, 1) = txtEnt.InsertionPoint(1)&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  'now you have an array of 2d coordinates, do&lt;BR /&gt;
  'a google for a function that will sort 2d&lt;BR /&gt;
  'coordinate arrays.&lt;BR /&gt;
&lt;BR /&gt;
  Dim j As Integer&lt;BR /&gt;
 'relate sorted coords back to your SS ents&lt;BR /&gt;
 'doesn't consider duplicate insertion points&lt;BR /&gt;
  For i = LBound(coords) To UBound(coords)&lt;BR /&gt;
    For j = 0 To SS.Count - 1&lt;BR /&gt;
      Set txtEnt = SS(j)&lt;BR /&gt;
      If txtEnt.InsertionPoint(0) = coords(i, 0) And _&lt;BR /&gt;
          txtEnt.InsertionPoint(1) = coords(i, 1) Then&lt;BR /&gt;
          'add text value to your table&lt;BR /&gt;
          Exit For&lt;BR /&gt;
      End If&lt;BR /&gt;
    Next j&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  Call SSRemove("test")&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Function SSAdd(inName As String) As AcadSelectionSet&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  With ThisDrawing&lt;BR /&gt;
    .SelectionSets(inName).Delete&lt;BR /&gt;
    Set SSAdd = .SelectionSets.Add(inName)&lt;BR /&gt;
  End With&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Sub SSRemove(inName As String)&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  ThisDrawing.SelectionSets(inName).Delete&lt;BR /&gt;
End Sub&lt;BR /&gt;
[/code]&lt;BR /&gt;
&lt;BR /&gt;
"Dan" &lt;DANDERSON&gt; wrote in message&lt;BR /&gt;
news:5213024@discussion.autodesk.com...&lt;BR /&gt;
I really do not understand most of what is happening in the heap sort&lt;BR /&gt;
method, but I will learn it. I appreciate all the help.  This code is much&lt;BR /&gt;
more advanced than I have ever written.  I was hoping to learn some new&lt;BR /&gt;
tricks, but found a whole new area of coding I can explore.&lt;BR /&gt;
&lt;BR /&gt;
Thanks again,&lt;BR /&gt;
Dan&lt;/DANDERSON&gt;&lt;/PRICHARDSONATADELPHIA.NET&gt;</description>
      <pubDate>Wed, 21 Jun 2006 00:07:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680032#M33441</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-21T00:07:49Z</dc:date>
    </item>
    <item>
      <title>Re: Sort an array of text objects Asc by their X and Y insertion point  values</title>
      <link>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680033#M33442</link>
      <description>Here ya go...Very simple I just subtracted the Y insertion&lt;BR /&gt;
point from the X insertion point and used the difference to&lt;BR /&gt;
sort.&lt;BR /&gt;
&lt;BR /&gt;
[code]&lt;BR /&gt;
Option Explicit&lt;BR /&gt;
Const dictKey = 1&lt;BR /&gt;
Const dictItem = 2&lt;BR /&gt;
&lt;BR /&gt;
 Sub Stub()&lt;BR /&gt;
  Dim SS As AcadSelectionSet&lt;BR /&gt;
  Dim filType(0) As Integer&lt;BR /&gt;
  Dim filData(0)&lt;BR /&gt;
  filType(0) = 0&lt;BR /&gt;
  filData(0) = "TEXT"&lt;BR /&gt;
&lt;BR /&gt;
  Set SS = SSAdd("test")&lt;BR /&gt;
  SS.SelectOnScreen filType, filData&lt;BR /&gt;
&lt;BR /&gt;
  Dim Dict As Scripting.Dictionary&lt;BR /&gt;
  Set Dict = SSToDictionary(SS)&lt;BR /&gt;
  SortDictionary Dict, dictItem&lt;BR /&gt;
&lt;BR /&gt;
  'iterate sorted collection use Dict.Key to get&lt;BR /&gt;
  'the ents.&lt;BR /&gt;
  Dim i As Integer&lt;BR /&gt;
  Dim txt As AcadText&lt;BR /&gt;
  For i = 0 To Dict.Count - 1&lt;BR /&gt;
    Set txt = ThisDrawing.HandleToObject(Dict.Keys(i))&lt;BR /&gt;
    txt.TextString = i 'test only remove&lt;BR /&gt;
    'add to your table&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  Call SSRemove("test")&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
'Add ss ents to Dictionary using ent.handle as key and ents&lt;BR /&gt;
'(xIns - yIns) as item.&lt;BR /&gt;
Function SSToDictionary(inSS As AcadSelectionSet) As Scripting.Dictionary&lt;BR /&gt;
  Dim i As Integer&lt;BR /&gt;
&lt;BR /&gt;
  Dim txt As AcadText&lt;BR /&gt;
  Dim Dict As New Scripting.Dictionary&lt;BR /&gt;
&lt;BR /&gt;
  For i = 0 To inSS.Count - 1&lt;BR /&gt;
    Set txt = inSS(i)&lt;BR /&gt;
     Dict.Add txt.Handle, _&lt;BR /&gt;
      (VBA.Round((CStr(txt.InsertionPoint(0) - txt.InsertionPoint(1))), 2))&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  Set SSToDictionary = Dict&lt;BR /&gt;
&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Function SSAdd(inName As String) As AcadSelectionSet&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  With ThisDrawing&lt;BR /&gt;
    .SelectionSets(inName).Delete&lt;BR /&gt;
    Set SSAdd = .SelectionSets.Add(inName)&lt;BR /&gt;
  End With&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Sub SSRemove(inName As String)&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  ThisDrawing.SelectionSets(inName).Delete&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
'Modified MSDN Function&lt;BR /&gt;
Function SortDictionary(objDict, intSort)&lt;BR /&gt;
  ' declare our variables&lt;BR /&gt;
  Dim Dict()&lt;BR /&gt;
  Dim objKey&lt;BR /&gt;
  Dim strKey, strItem&lt;BR /&gt;
  Dim X, Y, Z&lt;BR /&gt;
&lt;BR /&gt;
  ' get the dictionary count&lt;BR /&gt;
  Z = objDict.Count&lt;BR /&gt;
&lt;BR /&gt;
  ' we need more than one item to warrant sorting&lt;BR /&gt;
  If Z &amp;gt; 1 Then&lt;BR /&gt;
    ' create an array to store dictionary information&lt;BR /&gt;
    ReDim Dict(Z, 2)&lt;BR /&gt;
    X = 0&lt;BR /&gt;
    ' populate the array&lt;BR /&gt;
    For Each objKey In objDict&lt;BR /&gt;
        Dict(X, dictKey) = (objKey)&lt;BR /&gt;
        Dict(X, dictItem) = (objDict(objKey))&lt;BR /&gt;
        X = X + 1&lt;BR /&gt;
    Next&lt;BR /&gt;
&lt;BR /&gt;
    ' perform a a shell sort of the string array&lt;BR /&gt;
    For X = 0 To (Z - 2)&lt;BR /&gt;
      For Y = X To (Z - 1)&lt;BR /&gt;
        If Dict(X, intSort) &amp;gt; Dict(Y, intSort) Then&lt;BR /&gt;
            strKey = Dict(X, dictKey)&lt;BR /&gt;
            strItem = Dict(X, dictItem)&lt;BR /&gt;
            Dict(X, dictKey) = Dict(Y, dictKey)&lt;BR /&gt;
            Dict(X, dictItem) = Dict(Y, dictItem)&lt;BR /&gt;
            Dict(Y, dictKey) = strKey&lt;BR /&gt;
            Dict(Y, dictItem) = strItem&lt;BR /&gt;
        End If&lt;BR /&gt;
      Next&lt;BR /&gt;
    Next&lt;BR /&gt;
&lt;BR /&gt;
    ' erase the contents of the dictionary object&lt;BR /&gt;
    objDict.RemoveAll&lt;BR /&gt;
&lt;BR /&gt;
    ' repopulate the dictionary with the sorted information&lt;BR /&gt;
    For X = 0 To (Z - 1)&lt;BR /&gt;
      objDict.Add Dict(X, dictKey), Dict(X, dictItem)&lt;BR /&gt;
    Next&lt;BR /&gt;
&lt;BR /&gt;
  End If&lt;BR /&gt;
&lt;BR /&gt;
End Function&lt;BR /&gt;
[/code]&lt;BR /&gt;
&lt;BR /&gt;
"Dan" &lt;DANDERSON&gt; wrote in message &lt;BR /&gt;
news:5213107@discussion.autodesk.com...&lt;BR /&gt;
Thank you so much. I will attemp to incorporate this new code and&lt;BR /&gt;
information into my routine.&lt;BR /&gt;
Thanks again for all your help.  When complete, this will save a tremendous&lt;BR /&gt;
amount of rework.&lt;BR /&gt;
&lt;BR /&gt;
Dan&lt;BR /&gt;
&lt;BR /&gt;
"Paul Richardson" &lt;PRICHARDSONATADELPHIA.NET&gt; wrote in message&lt;BR /&gt;
news:5213115@discussion.autodesk.com...&lt;BR /&gt;
The nice thing is you don't have to know what is going in the sort&lt;BR /&gt;
methods, just that it returns a sorted something for now...&lt;BR /&gt;
&lt;BR /&gt;
That being said, here is code to add the x and y insertion coords to a 2d&lt;BR /&gt;
array,&lt;BR /&gt;
and then relate a sorted 2d array of insertion points back to entities in&lt;BR /&gt;
your selection set.&lt;BR /&gt;
&lt;BR /&gt;
You need a function to sort 2d arrays...google "Sort 2d coordinates" or such&lt;BR /&gt;
&lt;BR /&gt;
[code]&lt;BR /&gt;
 Sub Stub()&lt;BR /&gt;
  Dim SS As AcadSelectionSet&lt;BR /&gt;
  Dim filType(0) As Integer&lt;BR /&gt;
  Dim filData(0)&lt;BR /&gt;
  'filter data for TEXT&lt;BR /&gt;
  filType(0) = 0&lt;BR /&gt;
  filData(0) = "TEXT"&lt;BR /&gt;
&lt;BR /&gt;
  Set SS = SSAdd("test")&lt;BR /&gt;
  SS.SelectOnScreen filType, filData&lt;BR /&gt;
  'create 2d array (x,y) same size as your SS&lt;BR /&gt;
  ReDim coords(SS.Count - 1, 1)&lt;BR /&gt;
&lt;BR /&gt;
  Dim txtEnt As AcadText&lt;BR /&gt;
  Dim i As Integer&lt;BR /&gt;
&lt;BR /&gt;
  For i = 0 To SS.Count - 1&lt;BR /&gt;
    Set txtEnt = SS(i)&lt;BR /&gt;
    coords(i, 0) = txtEnt.InsertionPoint(0)&lt;BR /&gt;
    coords(i, 1) = txtEnt.InsertionPoint(1)&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  'now you have an array of 2d coordinates, do&lt;BR /&gt;
  'a google for a function that will sort 2d&lt;BR /&gt;
  'coordinate arrays.&lt;BR /&gt;
&lt;BR /&gt;
  Dim j As Integer&lt;BR /&gt;
 'relate sorted coords back to your SS ents&lt;BR /&gt;
 'doesn't consider duplicate insertion points&lt;BR /&gt;
  For i = LBound(coords) To UBound(coords)&lt;BR /&gt;
    For j = 0 To SS.Count - 1&lt;BR /&gt;
      Set txtEnt = SS(j)&lt;BR /&gt;
      If txtEnt.InsertionPoint(0) = coords(i, 0) And _&lt;BR /&gt;
          txtEnt.InsertionPoint(1) = coords(i, 1) Then&lt;BR /&gt;
          'add text value to your table&lt;BR /&gt;
          Exit For&lt;BR /&gt;
      End If&lt;BR /&gt;
    Next j&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  Call SSRemove("test")&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Function SSAdd(inName As String) As AcadSelectionSet&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  With ThisDrawing&lt;BR /&gt;
    .SelectionSets(inName).Delete&lt;BR /&gt;
    Set SSAdd = .SelectionSets.Add(inName)&lt;BR /&gt;
  End With&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Sub SSRemove(inName As String)&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  ThisDrawing.SelectionSets(inName).Delete&lt;BR /&gt;
End Sub&lt;BR /&gt;
[/code]&lt;BR /&gt;
&lt;BR /&gt;
"Dan" &lt;DANDERSON&gt; wrote in message&lt;BR /&gt;
news:5213024@discussion.autodesk.com...&lt;BR /&gt;
I really do not understand most of what is happening in the heap sort&lt;BR /&gt;
method, but I will learn it. I appreciate all the help.  This code is much&lt;BR /&gt;
more advanced than I have ever written.  I was hoping to learn some new&lt;BR /&gt;
tricks, but found a whole new area of coding I can explore.&lt;BR /&gt;
&lt;BR /&gt;
Thanks again,&lt;BR /&gt;
Dan&lt;/DANDERSON&gt;&lt;/PRICHARDSONATADELPHIA.NET&gt;&lt;/DANDERSON&gt;</description>
      <pubDate>Wed, 21 Jun 2006 03:26:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680033#M33442</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-21T03:26:49Z</dc:date>
    </item>
    <item>
      <title>Re: Sort an array of text objects Asc by their X and Y insertion point  values</title>
      <link>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680034#M33443</link>
      <description>you need to reference the "microsoft scripting runtime" but the&lt;BR /&gt;
idea doesn't work anyway...I should have tired it first..&lt;BR /&gt;
&lt;BR /&gt;
"Paul Richardson" &lt;PRICHARDSONATADELPHIA.NET&gt; wrote in message &lt;BR /&gt;
news:5213225@discussion.autodesk.com...&lt;BR /&gt;
Here ya go...Very simple I just subtracted the Y insertion&lt;BR /&gt;
point from the X insertion point and used the difference to&lt;BR /&gt;
sort.&lt;BR /&gt;
&lt;BR /&gt;
[code]&lt;BR /&gt;
Option Explicit&lt;BR /&gt;
Const dictKey = 1&lt;BR /&gt;
Const dictItem = 2&lt;BR /&gt;
&lt;BR /&gt;
 Sub Stub()&lt;BR /&gt;
  Dim SS As AcadSelectionSet&lt;BR /&gt;
  Dim filType(0) As Integer&lt;BR /&gt;
  Dim filData(0)&lt;BR /&gt;
  filType(0) = 0&lt;BR /&gt;
  filData(0) = "TEXT"&lt;BR /&gt;
&lt;BR /&gt;
  Set SS = SSAdd("test")&lt;BR /&gt;
  SS.SelectOnScreen filType, filData&lt;BR /&gt;
&lt;BR /&gt;
  Dim Dict As Scripting.Dictionary&lt;BR /&gt;
  Set Dict = SSToDictionary(SS)&lt;BR /&gt;
  SortDictionary Dict, dictItem&lt;BR /&gt;
&lt;BR /&gt;
  'iterate sorted collection use Dict.Key to get&lt;BR /&gt;
  'the ents.&lt;BR /&gt;
  Dim i As Integer&lt;BR /&gt;
  Dim txt As AcadText&lt;BR /&gt;
  For i = 0 To Dict.Count - 1&lt;BR /&gt;
    Set txt = ThisDrawing.HandleToObject(Dict.Keys(i))&lt;BR /&gt;
    txt.TextString = i 'test only remove&lt;BR /&gt;
    'add to your table&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  Call SSRemove("test")&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
'Add ss ents to Dictionary using ent.handle as key and ents&lt;BR /&gt;
'(xIns - yIns) as item.&lt;BR /&gt;
Function SSToDictionary(inSS As AcadSelectionSet) As Scripting.Dictionary&lt;BR /&gt;
  Dim i As Integer&lt;BR /&gt;
&lt;BR /&gt;
  Dim txt As AcadText&lt;BR /&gt;
  Dim Dict As New Scripting.Dictionary&lt;BR /&gt;
&lt;BR /&gt;
  For i = 0 To inSS.Count - 1&lt;BR /&gt;
    Set txt = inSS(i)&lt;BR /&gt;
     Dict.Add txt.Handle, _&lt;BR /&gt;
      (VBA.Round((CStr(txt.InsertionPoint(0) - txt.InsertionPoint(1))), 2))&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  Set SSToDictionary = Dict&lt;BR /&gt;
&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Function SSAdd(inName As String) As AcadSelectionSet&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  With ThisDrawing&lt;BR /&gt;
    .SelectionSets(inName).Delete&lt;BR /&gt;
    Set SSAdd = .SelectionSets.Add(inName)&lt;BR /&gt;
  End With&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Sub SSRemove(inName As String)&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  ThisDrawing.SelectionSets(inName).Delete&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
'Modified MSDN Function&lt;BR /&gt;
Function SortDictionary(objDict, intSort)&lt;BR /&gt;
  ' declare our variables&lt;BR /&gt;
  Dim Dict()&lt;BR /&gt;
  Dim objKey&lt;BR /&gt;
  Dim strKey, strItem&lt;BR /&gt;
  Dim X, Y, Z&lt;BR /&gt;
&lt;BR /&gt;
  ' get the dictionary count&lt;BR /&gt;
  Z = objDict.Count&lt;BR /&gt;
&lt;BR /&gt;
  ' we need more than one item to warrant sorting&lt;BR /&gt;
  If Z &amp;gt; 1 Then&lt;BR /&gt;
    ' create an array to store dictionary information&lt;BR /&gt;
    ReDim Dict(Z, 2)&lt;BR /&gt;
    X = 0&lt;BR /&gt;
    ' populate the array&lt;BR /&gt;
    For Each objKey In objDict&lt;BR /&gt;
        Dict(X, dictKey) = (objKey)&lt;BR /&gt;
        Dict(X, dictItem) = (objDict(objKey))&lt;BR /&gt;
        X = X + 1&lt;BR /&gt;
    Next&lt;BR /&gt;
&lt;BR /&gt;
    ' perform a a shell sort of the string array&lt;BR /&gt;
    For X = 0 To (Z - 2)&lt;BR /&gt;
      For Y = X To (Z - 1)&lt;BR /&gt;
        If Dict(X, intSort) &amp;gt; Dict(Y, intSort) Then&lt;BR /&gt;
            strKey = Dict(X, dictKey)&lt;BR /&gt;
            strItem = Dict(X, dictItem)&lt;BR /&gt;
            Dict(X, dictKey) = Dict(Y, dictKey)&lt;BR /&gt;
            Dict(X, dictItem) = Dict(Y, dictItem)&lt;BR /&gt;
            Dict(Y, dictKey) = strKey&lt;BR /&gt;
            Dict(Y, dictItem) = strItem&lt;BR /&gt;
        End If&lt;BR /&gt;
      Next&lt;BR /&gt;
    Next&lt;BR /&gt;
&lt;BR /&gt;
    ' erase the contents of the dictionary object&lt;BR /&gt;
    objDict.RemoveAll&lt;BR /&gt;
&lt;BR /&gt;
    ' repopulate the dictionary with the sorted information&lt;BR /&gt;
    For X = 0 To (Z - 1)&lt;BR /&gt;
      objDict.Add Dict(X, dictKey), Dict(X, dictItem)&lt;BR /&gt;
    Next&lt;BR /&gt;
&lt;BR /&gt;
  End If&lt;BR /&gt;
&lt;BR /&gt;
End Function&lt;BR /&gt;
[/code]&lt;BR /&gt;
&lt;BR /&gt;
"Dan" &lt;DANDERSON&gt; wrote in message&lt;BR /&gt;
news:5213107@discussion.autodesk.com...&lt;BR /&gt;
Thank you so much. I will attemp to incorporate this new code and&lt;BR /&gt;
information into my routine.&lt;BR /&gt;
Thanks again for all your help.  When complete, this will save a tremendous&lt;BR /&gt;
amount of rework.&lt;BR /&gt;
&lt;BR /&gt;
Dan&lt;BR /&gt;
&lt;BR /&gt;
"Paul Richardson" &lt;PRICHARDSONATADELPHIA.NET&gt; wrote in message&lt;BR /&gt;
news:5213115@discussion.autodesk.com...&lt;BR /&gt;
The nice thing is you don't have to know what is going in the sort&lt;BR /&gt;
methods, just that it returns a sorted something for now...&lt;BR /&gt;
&lt;BR /&gt;
That being said, here is code to add the x and y insertion coords to a 2d&lt;BR /&gt;
array,&lt;BR /&gt;
and then relate a sorted 2d array of insertion points back to entities in&lt;BR /&gt;
your selection set.&lt;BR /&gt;
&lt;BR /&gt;
You need a function to sort 2d arrays...google "Sort 2d coordinates" or such&lt;BR /&gt;
&lt;BR /&gt;
[code]&lt;BR /&gt;
 Sub Stub()&lt;BR /&gt;
  Dim SS As AcadSelectionSet&lt;BR /&gt;
  Dim filType(0) As Integer&lt;BR /&gt;
  Dim filData(0)&lt;BR /&gt;
  'filter data for TEXT&lt;BR /&gt;
  filType(0) = 0&lt;BR /&gt;
  filData(0) = "TEXT"&lt;BR /&gt;
&lt;BR /&gt;
  Set SS = SSAdd("test")&lt;BR /&gt;
  SS.SelectOnScreen filType, filData&lt;BR /&gt;
  'create 2d array (x,y) same size as your SS&lt;BR /&gt;
  ReDim coords(SS.Count - 1, 1)&lt;BR /&gt;
&lt;BR /&gt;
  Dim txtEnt As AcadText&lt;BR /&gt;
  Dim i As Integer&lt;BR /&gt;
&lt;BR /&gt;
  For i = 0 To SS.Count - 1&lt;BR /&gt;
    Set txtEnt = SS(i)&lt;BR /&gt;
    coords(i, 0) = txtEnt.InsertionPoint(0)&lt;BR /&gt;
    coords(i, 1) = txtEnt.InsertionPoint(1)&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  'now you have an array of 2d coordinates, do&lt;BR /&gt;
  'a google for a function that will sort 2d&lt;BR /&gt;
  'coordinate arrays.&lt;BR /&gt;
&lt;BR /&gt;
  Dim j As Integer&lt;BR /&gt;
 'relate sorted coords back to your SS ents&lt;BR /&gt;
 'doesn't consider duplicate insertion points&lt;BR /&gt;
  For i = LBound(coords) To UBound(coords)&lt;BR /&gt;
    For j = 0 To SS.Count - 1&lt;BR /&gt;
      Set txtEnt = SS(j)&lt;BR /&gt;
      If txtEnt.InsertionPoint(0) = coords(i, 0) And _&lt;BR /&gt;
          txtEnt.InsertionPoint(1) = coords(i, 1) Then&lt;BR /&gt;
          'add text value to your table&lt;BR /&gt;
          Exit For&lt;BR /&gt;
      End If&lt;BR /&gt;
    Next j&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  Call SSRemove("test")&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Function SSAdd(inName As String) As AcadSelectionSet&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  With ThisDrawing&lt;BR /&gt;
    .SelectionSets(inName).Delete&lt;BR /&gt;
    Set SSAdd = .SelectionSets.Add(inName)&lt;BR /&gt;
  End With&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Sub SSRemove(inName As String)&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  ThisDrawing.SelectionSets(inName).Delete&lt;BR /&gt;
End Sub&lt;BR /&gt;
[/code]&lt;BR /&gt;
&lt;BR /&gt;
"Dan" &lt;DANDERSON&gt; wrote in message&lt;BR /&gt;
news:5213024@discussion.autodesk.com...&lt;BR /&gt;
I really do not understand most of what is happening in the heap sort&lt;BR /&gt;
method, but I will learn it. I appreciate all the help.  This code is much&lt;BR /&gt;
more advanced than I have ever written.  I was hoping to learn some new&lt;BR /&gt;
tricks, but found a whole new area of coding I can explore.&lt;BR /&gt;
&lt;BR /&gt;
Thanks again,&lt;BR /&gt;
Dan&lt;/DANDERSON&gt;&lt;/PRICHARDSONATADELPHIA.NET&gt;&lt;/DANDERSON&gt;&lt;/PRICHARDSONATADELPHIA.NET&gt;</description>
      <pubDate>Wed, 21 Jun 2006 03:44:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680034#M33443</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-21T03:44:55Z</dc:date>
    </item>
    <item>
      <title>Re: Sort an array of text objects Asc by their X and Y insertion point  values</title>
      <link>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680035#M33444</link>
      <description>check out this link, it's in c but should give you&lt;BR /&gt;
some ideas...&lt;BR /&gt;
http://www.cedarcreek.umn.edu/tools/declare/sort.d.pdf&lt;BR /&gt;
&lt;BR /&gt;
"Paul Richardson" &lt;PRICHARDSONATADELPHIA.NET&gt; wrote in message &lt;BR /&gt;
news:5213243@discussion.autodesk.com...&lt;BR /&gt;
you need to reference the "microsoft scripting runtime" but the&lt;BR /&gt;
idea doesn't work anyway...I should have tired it first..&lt;BR /&gt;
&lt;BR /&gt;
"Paul Richardson" &lt;PRICHARDSONATADELPHIA.NET&gt; wrote in message&lt;BR /&gt;
news:5213225@discussion.autodesk.com...&lt;BR /&gt;
Here ya go...Very simple I just subtracted the Y insertion&lt;BR /&gt;
point from the X insertion point and used the difference to&lt;BR /&gt;
sort.&lt;BR /&gt;
&lt;BR /&gt;
[code]&lt;BR /&gt;
Option Explicit&lt;BR /&gt;
Const dictKey = 1&lt;BR /&gt;
Const dictItem = 2&lt;BR /&gt;
&lt;BR /&gt;
 Sub Stub()&lt;BR /&gt;
  Dim SS As AcadSelectionSet&lt;BR /&gt;
  Dim filType(0) As Integer&lt;BR /&gt;
  Dim filData(0)&lt;BR /&gt;
  filType(0) = 0&lt;BR /&gt;
  filData(0) = "TEXT"&lt;BR /&gt;
&lt;BR /&gt;
  Set SS = SSAdd("test")&lt;BR /&gt;
  SS.SelectOnScreen filType, filData&lt;BR /&gt;
&lt;BR /&gt;
  Dim Dict As Scripting.Dictionary&lt;BR /&gt;
  Set Dict = SSToDictionary(SS)&lt;BR /&gt;
  SortDictionary Dict, dictItem&lt;BR /&gt;
&lt;BR /&gt;
  'iterate sorted collection use Dict.Key to get&lt;BR /&gt;
  'the ents.&lt;BR /&gt;
  Dim i As Integer&lt;BR /&gt;
  Dim txt As AcadText&lt;BR /&gt;
  For i = 0 To Dict.Count - 1&lt;BR /&gt;
    Set txt = ThisDrawing.HandleToObject(Dict.Keys(i))&lt;BR /&gt;
    txt.TextString = i 'test only remove&lt;BR /&gt;
    'add to your table&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  Call SSRemove("test")&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
'Add ss ents to Dictionary using ent.handle as key and ents&lt;BR /&gt;
'(xIns - yIns) as item.&lt;BR /&gt;
Function SSToDictionary(inSS As AcadSelectionSet) As Scripting.Dictionary&lt;BR /&gt;
  Dim i As Integer&lt;BR /&gt;
&lt;BR /&gt;
  Dim txt As AcadText&lt;BR /&gt;
  Dim Dict As New Scripting.Dictionary&lt;BR /&gt;
&lt;BR /&gt;
  For i = 0 To inSS.Count - 1&lt;BR /&gt;
    Set txt = inSS(i)&lt;BR /&gt;
     Dict.Add txt.Handle, _&lt;BR /&gt;
      (VBA.Round((CStr(txt.InsertionPoint(0) - txt.InsertionPoint(1))), 2))&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  Set SSToDictionary = Dict&lt;BR /&gt;
&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Function SSAdd(inName As String) As AcadSelectionSet&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  With ThisDrawing&lt;BR /&gt;
    .SelectionSets(inName).Delete&lt;BR /&gt;
    Set SSAdd = .SelectionSets.Add(inName)&lt;BR /&gt;
  End With&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Sub SSRemove(inName As String)&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  ThisDrawing.SelectionSets(inName).Delete&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
'Modified MSDN Function&lt;BR /&gt;
Function SortDictionary(objDict, intSort)&lt;BR /&gt;
  ' declare our variables&lt;BR /&gt;
  Dim Dict()&lt;BR /&gt;
  Dim objKey&lt;BR /&gt;
  Dim strKey, strItem&lt;BR /&gt;
  Dim X, Y, Z&lt;BR /&gt;
&lt;BR /&gt;
  ' get the dictionary count&lt;BR /&gt;
  Z = objDict.Count&lt;BR /&gt;
&lt;BR /&gt;
  ' we need more than one item to warrant sorting&lt;BR /&gt;
  If Z &amp;gt; 1 Then&lt;BR /&gt;
    ' create an array to store dictionary information&lt;BR /&gt;
    ReDim Dict(Z, 2)&lt;BR /&gt;
    X = 0&lt;BR /&gt;
    ' populate the array&lt;BR /&gt;
    For Each objKey In objDict&lt;BR /&gt;
        Dict(X, dictKey) = (objKey)&lt;BR /&gt;
        Dict(X, dictItem) = (objDict(objKey))&lt;BR /&gt;
        X = X + 1&lt;BR /&gt;
    Next&lt;BR /&gt;
&lt;BR /&gt;
    ' perform a a shell sort of the string array&lt;BR /&gt;
    For X = 0 To (Z - 2)&lt;BR /&gt;
      For Y = X To (Z - 1)&lt;BR /&gt;
        If Dict(X, intSort) &amp;gt; Dict(Y, intSort) Then&lt;BR /&gt;
            strKey = Dict(X, dictKey)&lt;BR /&gt;
            strItem = Dict(X, dictItem)&lt;BR /&gt;
            Dict(X, dictKey) = Dict(Y, dictKey)&lt;BR /&gt;
            Dict(X, dictItem) = Dict(Y, dictItem)&lt;BR /&gt;
            Dict(Y, dictKey) = strKey&lt;BR /&gt;
            Dict(Y, dictItem) = strItem&lt;BR /&gt;
        End If&lt;BR /&gt;
      Next&lt;BR /&gt;
    Next&lt;BR /&gt;
&lt;BR /&gt;
    ' erase the contents of the dictionary object&lt;BR /&gt;
    objDict.RemoveAll&lt;BR /&gt;
&lt;BR /&gt;
    ' repopulate the dictionary with the sorted information&lt;BR /&gt;
    For X = 0 To (Z - 1)&lt;BR /&gt;
      objDict.Add Dict(X, dictKey), Dict(X, dictItem)&lt;BR /&gt;
    Next&lt;BR /&gt;
&lt;BR /&gt;
  End If&lt;BR /&gt;
&lt;BR /&gt;
End Function&lt;BR /&gt;
[/code]&lt;BR /&gt;
&lt;BR /&gt;
"Dan" &lt;DANDERSON&gt; wrote in message&lt;BR /&gt;
news:5213107@discussion.autodesk.com...&lt;BR /&gt;
Thank you so much. I will attemp to incorporate this new code and&lt;BR /&gt;
information into my routine.&lt;BR /&gt;
Thanks again for all your help.  When complete, this will save a tremendous&lt;BR /&gt;
amount of rework.&lt;BR /&gt;
&lt;BR /&gt;
Dan&lt;BR /&gt;
&lt;BR /&gt;
"Paul Richardson" &lt;PRICHARDSONATADELPHIA.NET&gt; wrote in message&lt;BR /&gt;
news:5213115@discussion.autodesk.com...&lt;BR /&gt;
The nice thing is you don't have to know what is going in the sort&lt;BR /&gt;
methods, just that it returns a sorted something for now...&lt;BR /&gt;
&lt;BR /&gt;
That being said, here is code to add the x and y insertion coords to a 2d&lt;BR /&gt;
array,&lt;BR /&gt;
and then relate a sorted 2d array of insertion points back to entities in&lt;BR /&gt;
your selection set.&lt;BR /&gt;
&lt;BR /&gt;
You need a function to sort 2d arrays...google "Sort 2d coordinates" or such&lt;BR /&gt;
&lt;BR /&gt;
[code]&lt;BR /&gt;
 Sub Stub()&lt;BR /&gt;
  Dim SS As AcadSelectionSet&lt;BR /&gt;
  Dim filType(0) As Integer&lt;BR /&gt;
  Dim filData(0)&lt;BR /&gt;
  'filter data for TEXT&lt;BR /&gt;
  filType(0) = 0&lt;BR /&gt;
  filData(0) = "TEXT"&lt;BR /&gt;
&lt;BR /&gt;
  Set SS = SSAdd("test")&lt;BR /&gt;
  SS.SelectOnScreen filType, filData&lt;BR /&gt;
  'create 2d array (x,y) same size as your SS&lt;BR /&gt;
  ReDim coords(SS.Count - 1, 1)&lt;BR /&gt;
&lt;BR /&gt;
  Dim txtEnt As AcadText&lt;BR /&gt;
  Dim i As Integer&lt;BR /&gt;
&lt;BR /&gt;
  For i = 0 To SS.Count - 1&lt;BR /&gt;
    Set txtEnt = SS(i)&lt;BR /&gt;
    coords(i, 0) = txtEnt.InsertionPoint(0)&lt;BR /&gt;
    coords(i, 1) = txtEnt.InsertionPoint(1)&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  'now you have an array of 2d coordinates, do&lt;BR /&gt;
  'a google for a function that will sort 2d&lt;BR /&gt;
  'coordinate arrays.&lt;BR /&gt;
&lt;BR /&gt;
  Dim j As Integer&lt;BR /&gt;
 'relate sorted coords back to your SS ents&lt;BR /&gt;
 'doesn't consider duplicate insertion points&lt;BR /&gt;
  For i = LBound(coords) To UBound(coords)&lt;BR /&gt;
    For j = 0 To SS.Count - 1&lt;BR /&gt;
      Set txtEnt = SS(j)&lt;BR /&gt;
      If txtEnt.InsertionPoint(0) = coords(i, 0) And _&lt;BR /&gt;
          txtEnt.InsertionPoint(1) = coords(i, 1) Then&lt;BR /&gt;
          'add text value to your table&lt;BR /&gt;
          Exit For&lt;BR /&gt;
      End If&lt;BR /&gt;
    Next j&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  Call SSRemove("test")&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Function SSAdd(inName As String) As AcadSelectionSet&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  With ThisDrawing&lt;BR /&gt;
    .SelectionSets(inName).Delete&lt;BR /&gt;
    Set SSAdd = .SelectionSets.Add(inName)&lt;BR /&gt;
  End With&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Sub SSRemove(inName As String)&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  ThisDrawing.SelectionSets(inName).Delete&lt;BR /&gt;
End Sub&lt;BR /&gt;
[/code]&lt;BR /&gt;
&lt;BR /&gt;
"Dan" &lt;DANDERSON&gt; wrote in message&lt;BR /&gt;
news:5213024@discussion.autodesk.com...&lt;BR /&gt;
I really do not understand most of what is happening in the heap sort&lt;BR /&gt;
method, but I will learn it. I appreciate all the help.  This code is much&lt;BR /&gt;
more advanced than I have ever written.  I was hoping to learn some new&lt;BR /&gt;
tricks, but found a whole new area of coding I can explore.&lt;BR /&gt;
&lt;BR /&gt;
Thanks again,&lt;BR /&gt;
Dan&lt;/DANDERSON&gt;&lt;/PRICHARDSONATADELPHIA.NET&gt;&lt;/DANDERSON&gt;&lt;/PRICHARDSONATADELPHIA.NET&gt;&lt;/PRICHARDSONATADELPHIA.NET&gt;</description>
      <pubDate>Wed, 21 Jun 2006 11:53:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680035#M33444</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-21T11:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: Sort an array of text objects Asc by their X and Y insertion point  values</title>
      <link>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680036#M33445</link>
      <description>Thank you, I will try to read more. I am a newbie at VBA, and this sorting &lt;BR /&gt;
algorithun code is really unfamiliar to me.&lt;BR /&gt;
&lt;BR /&gt;
"Paul Richardson" &lt;PRICHARDSONATADELPHIA.NET&gt; wrote in message &lt;BR /&gt;
news:5213519@discussion.autodesk.com...&lt;BR /&gt;
check out this link, it's in c but should give you&lt;BR /&gt;
some ideas...&lt;BR /&gt;
http://www.cedarcreek.umn.edu/tools/declare/sort.d.pdf&lt;BR /&gt;
&lt;BR /&gt;
"Paul Richardson" &lt;PRICHARDSONATADELPHIA.NET&gt; wrote in message&lt;BR /&gt;
news:5213243@discussion.autodesk.com...&lt;BR /&gt;
you need to reference the "microsoft scripting runtime" but the&lt;BR /&gt;
idea doesn't work anyway...I should have tired it first..&lt;BR /&gt;
&lt;BR /&gt;
"Paul Richardson" &lt;PRICHARDSONATADELPHIA.NET&gt; wrote in message&lt;BR /&gt;
news:5213225@discussion.autodesk.com...&lt;BR /&gt;
Here ya go...Very simple I just subtracted the Y insertion&lt;BR /&gt;
point from the X insertion point and used the difference to&lt;BR /&gt;
sort.&lt;BR /&gt;
&lt;BR /&gt;
[code]&lt;BR /&gt;
Option Explicit&lt;BR /&gt;
Const dictKey = 1&lt;BR /&gt;
Const dictItem = 2&lt;BR /&gt;
&lt;BR /&gt;
 Sub Stub()&lt;BR /&gt;
  Dim SS As AcadSelectionSet&lt;BR /&gt;
  Dim filType(0) As Integer&lt;BR /&gt;
  Dim filData(0)&lt;BR /&gt;
  filType(0) = 0&lt;BR /&gt;
  filData(0) = "TEXT"&lt;BR /&gt;
&lt;BR /&gt;
  Set SS = SSAdd("test")&lt;BR /&gt;
  SS.SelectOnScreen filType, filData&lt;BR /&gt;
&lt;BR /&gt;
  Dim Dict As Scripting.Dictionary&lt;BR /&gt;
  Set Dict = SSToDictionary(SS)&lt;BR /&gt;
  SortDictionary Dict, dictItem&lt;BR /&gt;
&lt;BR /&gt;
  'iterate sorted collection use Dict.Key to get&lt;BR /&gt;
  'the ents.&lt;BR /&gt;
  Dim i As Integer&lt;BR /&gt;
  Dim txt As AcadText&lt;BR /&gt;
  For i = 0 To Dict.Count - 1&lt;BR /&gt;
    Set txt = ThisDrawing.HandleToObject(Dict.Keys(i))&lt;BR /&gt;
    txt.TextString = i 'test only remove&lt;BR /&gt;
    'add to your table&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  Call SSRemove("test")&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
'Add ss ents to Dictionary using ent.handle as key and ents&lt;BR /&gt;
'(xIns - yIns) as item.&lt;BR /&gt;
Function SSToDictionary(inSS As AcadSelectionSet) As Scripting.Dictionary&lt;BR /&gt;
  Dim i As Integer&lt;BR /&gt;
&lt;BR /&gt;
  Dim txt As AcadText&lt;BR /&gt;
  Dim Dict As New Scripting.Dictionary&lt;BR /&gt;
&lt;BR /&gt;
  For i = 0 To inSS.Count - 1&lt;BR /&gt;
    Set txt = inSS(i)&lt;BR /&gt;
     Dict.Add txt.Handle, _&lt;BR /&gt;
      (VBA.Round((CStr(txt.InsertionPoint(0) - txt.InsertionPoint(1))), 2))&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  Set SSToDictionary = Dict&lt;BR /&gt;
&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Function SSAdd(inName As String) As AcadSelectionSet&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  With ThisDrawing&lt;BR /&gt;
    .SelectionSets(inName).Delete&lt;BR /&gt;
    Set SSAdd = .SelectionSets.Add(inName)&lt;BR /&gt;
  End With&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Sub SSRemove(inName As String)&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  ThisDrawing.SelectionSets(inName).Delete&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
'Modified MSDN Function&lt;BR /&gt;
Function SortDictionary(objDict, intSort)&lt;BR /&gt;
  ' declare our variables&lt;BR /&gt;
  Dim Dict()&lt;BR /&gt;
  Dim objKey&lt;BR /&gt;
  Dim strKey, strItem&lt;BR /&gt;
  Dim X, Y, Z&lt;BR /&gt;
&lt;BR /&gt;
  ' get the dictionary count&lt;BR /&gt;
  Z = objDict.Count&lt;BR /&gt;
&lt;BR /&gt;
  ' we need more than one item to warrant sorting&lt;BR /&gt;
  If Z &amp;gt; 1 Then&lt;BR /&gt;
    ' create an array to store dictionary information&lt;BR /&gt;
    ReDim Dict(Z, 2)&lt;BR /&gt;
    X = 0&lt;BR /&gt;
    ' populate the array&lt;BR /&gt;
    For Each objKey In objDict&lt;BR /&gt;
        Dict(X, dictKey) = (objKey)&lt;BR /&gt;
        Dict(X, dictItem) = (objDict(objKey))&lt;BR /&gt;
        X = X + 1&lt;BR /&gt;
    Next&lt;BR /&gt;
&lt;BR /&gt;
    ' perform a a shell sort of the string array&lt;BR /&gt;
    For X = 0 To (Z - 2)&lt;BR /&gt;
      For Y = X To (Z - 1)&lt;BR /&gt;
        If Dict(X, intSort) &amp;gt; Dict(Y, intSort) Then&lt;BR /&gt;
            strKey = Dict(X, dictKey)&lt;BR /&gt;
            strItem = Dict(X, dictItem)&lt;BR /&gt;
            Dict(X, dictKey) = Dict(Y, dictKey)&lt;BR /&gt;
            Dict(X, dictItem) = Dict(Y, dictItem)&lt;BR /&gt;
            Dict(Y, dictKey) = strKey&lt;BR /&gt;
            Dict(Y, dictItem) = strItem&lt;BR /&gt;
        End If&lt;BR /&gt;
      Next&lt;BR /&gt;
    Next&lt;BR /&gt;
&lt;BR /&gt;
    ' erase the contents of the dictionary object&lt;BR /&gt;
    objDict.RemoveAll&lt;BR /&gt;
&lt;BR /&gt;
    ' repopulate the dictionary with the sorted information&lt;BR /&gt;
    For X = 0 To (Z - 1)&lt;BR /&gt;
      objDict.Add Dict(X, dictKey), Dict(X, dictItem)&lt;BR /&gt;
    Next&lt;BR /&gt;
&lt;BR /&gt;
  End If&lt;BR /&gt;
&lt;BR /&gt;
End Function&lt;BR /&gt;
[/code]&lt;BR /&gt;
&lt;BR /&gt;
"Dan" &lt;DANDERSON&gt; wrote in message&lt;BR /&gt;
news:5213107@discussion.autodesk.com...&lt;BR /&gt;
Thank you so much. I will attemp to incorporate this new code and&lt;BR /&gt;
information into my routine.&lt;BR /&gt;
Thanks again for all your help.  When complete, this will save a tremendous&lt;BR /&gt;
amount of rework.&lt;BR /&gt;
&lt;BR /&gt;
Dan&lt;BR /&gt;
&lt;BR /&gt;
"Paul Richardson" &lt;PRICHARDSONATADELPHIA.NET&gt; wrote in message&lt;BR /&gt;
news:5213115@discussion.autodesk.com...&lt;BR /&gt;
The nice thing is you don't have to know what is going in the sort&lt;BR /&gt;
methods, just that it returns a sorted something for now...&lt;BR /&gt;
&lt;BR /&gt;
That being said, here is code to add the x and y insertion coords to a 2d&lt;BR /&gt;
array,&lt;BR /&gt;
and then relate a sorted 2d array of insertion points back to entities in&lt;BR /&gt;
your selection set.&lt;BR /&gt;
&lt;BR /&gt;
You need a function to sort 2d arrays...google "Sort 2d coordinates" or such&lt;BR /&gt;
&lt;BR /&gt;
[code]&lt;BR /&gt;
 Sub Stub()&lt;BR /&gt;
  Dim SS As AcadSelectionSet&lt;BR /&gt;
  Dim filType(0) As Integer&lt;BR /&gt;
  Dim filData(0)&lt;BR /&gt;
  'filter data for TEXT&lt;BR /&gt;
  filType(0) = 0&lt;BR /&gt;
  filData(0) = "TEXT"&lt;BR /&gt;
&lt;BR /&gt;
  Set SS = SSAdd("test")&lt;BR /&gt;
  SS.SelectOnScreen filType, filData&lt;BR /&gt;
  'create 2d array (x,y) same size as your SS&lt;BR /&gt;
  ReDim coords(SS.Count - 1, 1)&lt;BR /&gt;
&lt;BR /&gt;
  Dim txtEnt As AcadText&lt;BR /&gt;
  Dim i As Integer&lt;BR /&gt;
&lt;BR /&gt;
  For i = 0 To SS.Count - 1&lt;BR /&gt;
    Set txtEnt = SS(i)&lt;BR /&gt;
    coords(i, 0) = txtEnt.InsertionPoint(0)&lt;BR /&gt;
    coords(i, 1) = txtEnt.InsertionPoint(1)&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  'now you have an array of 2d coordinates, do&lt;BR /&gt;
  'a google for a function that will sort 2d&lt;BR /&gt;
  'coordinate arrays.&lt;BR /&gt;
&lt;BR /&gt;
  Dim j As Integer&lt;BR /&gt;
 'relate sorted coords back to your SS ents&lt;BR /&gt;
 'doesn't consider duplicate insertion points&lt;BR /&gt;
  For i = LBound(coords) To UBound(coords)&lt;BR /&gt;
    For j = 0 To SS.Count - 1&lt;BR /&gt;
      Set txtEnt = SS(j)&lt;BR /&gt;
      If txtEnt.InsertionPoint(0) = coords(i, 0) And _&lt;BR /&gt;
          txtEnt.InsertionPoint(1) = coords(i, 1) Then&lt;BR /&gt;
          'add text value to your table&lt;BR /&gt;
          Exit For&lt;BR /&gt;
      End If&lt;BR /&gt;
    Next j&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  Call SSRemove("test")&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Function SSAdd(inName As String) As AcadSelectionSet&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  With ThisDrawing&lt;BR /&gt;
    .SelectionSets(inName).Delete&lt;BR /&gt;
    Set SSAdd = .SelectionSets.Add(inName)&lt;BR /&gt;
  End With&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Sub SSRemove(inName As String)&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  ThisDrawing.SelectionSets(inName).Delete&lt;BR /&gt;
End Sub&lt;BR /&gt;
[/code]&lt;BR /&gt;
&lt;BR /&gt;
"Dan" &lt;DANDERSON&gt; wrote in message&lt;BR /&gt;
news:5213024@discussion.autodesk.com...&lt;BR /&gt;
I really do not understand most of what is happening in the heap sort&lt;BR /&gt;
method, but I will learn it. I appreciate all the help.  This code is much&lt;BR /&gt;
more advanced than I have ever written.  I was hoping to learn some new&lt;BR /&gt;
tricks, but found a whole new area of coding I can explore.&lt;BR /&gt;
&lt;BR /&gt;
Thanks again,&lt;BR /&gt;
Dan&lt;/DANDERSON&gt;&lt;/PRICHARDSONATADELPHIA.NET&gt;&lt;/DANDERSON&gt;&lt;/PRICHARDSONATADELPHIA.NET&gt;&lt;/PRICHARDSONATADELPHIA.NET&gt;&lt;/PRICHARDSONATADELPHIA.NET&gt;</description>
      <pubDate>Wed, 21 Jun 2006 15:19:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680036#M33445</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-21T15:19:08Z</dc:date>
    </item>
    <item>
      <title>Re: Sort an array of text objects Asc by their X and Y insertion point  values</title>
      <link>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680037#M33446</link>
      <description>Did you have an opportunity to view my example drawing?  I have 1000's of &lt;BR /&gt;
files with this configuration, I am trying to update.&lt;BR /&gt;
Fatty was kind enough to assist me with the initial code, but I am still &lt;BR /&gt;
hung up on the sorting.  Did you have an opportunity to run the existing &lt;BR /&gt;
code? If you select the text object individually, in order, the code works &lt;BR /&gt;
great, but when I have 164 entities, this will be to tedious, and time &lt;BR /&gt;
consuming.&lt;BR /&gt;
&lt;BR /&gt;
Once again, I appreciate your time and efforts.&lt;BR /&gt;
&lt;BR /&gt;
Dan&lt;BR /&gt;
&lt;BR /&gt;
"Dan" &lt;DANDERSON&gt; wrote in message &lt;BR /&gt;
news:5213872@discussion.autodesk.com...&lt;BR /&gt;
Thank you, I will try to read more. I am a newbie at VBA, and this sorting&lt;BR /&gt;
algorithun code is really unfamiliar to me.&lt;BR /&gt;
&lt;BR /&gt;
"Paul Richardson" &lt;PRICHARDSONATADELPHIA.NET&gt; wrote in message&lt;BR /&gt;
news:5213519@discussion.autodesk.com...&lt;BR /&gt;
check out this link, it's in c but should give you&lt;BR /&gt;
some ideas...&lt;BR /&gt;
http://www.cedarcreek.umn.edu/tools/declare/sort.d.pdf&lt;BR /&gt;
&lt;BR /&gt;
"Paul Richardson" &lt;PRICHARDSONATADELPHIA.NET&gt; wrote in message&lt;BR /&gt;
news:5213243@discussion.autodesk.com...&lt;BR /&gt;
you need to reference the "microsoft scripting runtime" but the&lt;BR /&gt;
idea doesn't work anyway...I should have tired it first..&lt;BR /&gt;
&lt;BR /&gt;
"Paul Richardson" &lt;PRICHARDSONATADELPHIA.NET&gt; wrote in message&lt;BR /&gt;
news:5213225@discussion.autodesk.com...&lt;BR /&gt;
Here ya go...Very simple I just subtracted the Y insertion&lt;BR /&gt;
point from the X insertion point and used the difference to&lt;BR /&gt;
sort.&lt;BR /&gt;
&lt;BR /&gt;
[code]&lt;BR /&gt;
Option Explicit&lt;BR /&gt;
Const dictKey = 1&lt;BR /&gt;
Const dictItem = 2&lt;BR /&gt;
&lt;BR /&gt;
 Sub Stub()&lt;BR /&gt;
  Dim SS As AcadSelectionSet&lt;BR /&gt;
  Dim filType(0) As Integer&lt;BR /&gt;
  Dim filData(0)&lt;BR /&gt;
  filType(0) = 0&lt;BR /&gt;
  filData(0) = "TEXT"&lt;BR /&gt;
&lt;BR /&gt;
  Set SS = SSAdd("test")&lt;BR /&gt;
  SS.SelectOnScreen filType, filData&lt;BR /&gt;
&lt;BR /&gt;
  Dim Dict As Scripting.Dictionary&lt;BR /&gt;
  Set Dict = SSToDictionary(SS)&lt;BR /&gt;
  SortDictionary Dict, dictItem&lt;BR /&gt;
&lt;BR /&gt;
  'iterate sorted collection use Dict.Key to get&lt;BR /&gt;
  'the ents.&lt;BR /&gt;
  Dim i As Integer&lt;BR /&gt;
  Dim txt As AcadText&lt;BR /&gt;
  For i = 0 To Dict.Count - 1&lt;BR /&gt;
    Set txt = ThisDrawing.HandleToObject(Dict.Keys(i))&lt;BR /&gt;
    txt.TextString = i 'test only remove&lt;BR /&gt;
    'add to your table&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  Call SSRemove("test")&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
'Add ss ents to Dictionary using ent.handle as key and ents&lt;BR /&gt;
'(xIns - yIns) as item.&lt;BR /&gt;
Function SSToDictionary(inSS As AcadSelectionSet) As Scripting.Dictionary&lt;BR /&gt;
  Dim i As Integer&lt;BR /&gt;
&lt;BR /&gt;
  Dim txt As AcadText&lt;BR /&gt;
  Dim Dict As New Scripting.Dictionary&lt;BR /&gt;
&lt;BR /&gt;
  For i = 0 To inSS.Count - 1&lt;BR /&gt;
    Set txt = inSS(i)&lt;BR /&gt;
     Dict.Add txt.Handle, _&lt;BR /&gt;
      (VBA.Round((CStr(txt.InsertionPoint(0) - txt.InsertionPoint(1))), 2))&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  Set SSToDictionary = Dict&lt;BR /&gt;
&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Function SSAdd(inName As String) As AcadSelectionSet&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  With ThisDrawing&lt;BR /&gt;
    .SelectionSets(inName).Delete&lt;BR /&gt;
    Set SSAdd = .SelectionSets.Add(inName)&lt;BR /&gt;
  End With&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Sub SSRemove(inName As String)&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  ThisDrawing.SelectionSets(inName).Delete&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
'Modified MSDN Function&lt;BR /&gt;
Function SortDictionary(objDict, intSort)&lt;BR /&gt;
  ' declare our variables&lt;BR /&gt;
  Dim Dict()&lt;BR /&gt;
  Dim objKey&lt;BR /&gt;
  Dim strKey, strItem&lt;BR /&gt;
  Dim X, Y, Z&lt;BR /&gt;
&lt;BR /&gt;
  ' get the dictionary count&lt;BR /&gt;
  Z = objDict.Count&lt;BR /&gt;
&lt;BR /&gt;
  ' we need more than one item to warrant sorting&lt;BR /&gt;
  If Z &amp;gt; 1 Then&lt;BR /&gt;
    ' create an array to store dictionary information&lt;BR /&gt;
    ReDim Dict(Z, 2)&lt;BR /&gt;
    X = 0&lt;BR /&gt;
    ' populate the array&lt;BR /&gt;
    For Each objKey In objDict&lt;BR /&gt;
        Dict(X, dictKey) = (objKey)&lt;BR /&gt;
        Dict(X, dictItem) = (objDict(objKey))&lt;BR /&gt;
        X = X + 1&lt;BR /&gt;
    Next&lt;BR /&gt;
&lt;BR /&gt;
    ' perform a a shell sort of the string array&lt;BR /&gt;
    For X = 0 To (Z - 2)&lt;BR /&gt;
      For Y = X To (Z - 1)&lt;BR /&gt;
        If Dict(X, intSort) &amp;gt; Dict(Y, intSort) Then&lt;BR /&gt;
            strKey = Dict(X, dictKey)&lt;BR /&gt;
            strItem = Dict(X, dictItem)&lt;BR /&gt;
            Dict(X, dictKey) = Dict(Y, dictKey)&lt;BR /&gt;
            Dict(X, dictItem) = Dict(Y, dictItem)&lt;BR /&gt;
            Dict(Y, dictKey) = strKey&lt;BR /&gt;
            Dict(Y, dictItem) = strItem&lt;BR /&gt;
        End If&lt;BR /&gt;
      Next&lt;BR /&gt;
    Next&lt;BR /&gt;
&lt;BR /&gt;
    ' erase the contents of the dictionary object&lt;BR /&gt;
    objDict.RemoveAll&lt;BR /&gt;
&lt;BR /&gt;
    ' repopulate the dictionary with the sorted information&lt;BR /&gt;
    For X = 0 To (Z - 1)&lt;BR /&gt;
      objDict.Add Dict(X, dictKey), Dict(X, dictItem)&lt;BR /&gt;
    Next&lt;BR /&gt;
&lt;BR /&gt;
  End If&lt;BR /&gt;
&lt;BR /&gt;
End Function&lt;BR /&gt;
[/code]&lt;BR /&gt;
&lt;BR /&gt;
"Dan" &lt;DANDERSON&gt; wrote in message&lt;BR /&gt;
news:5213107@discussion.autodesk.com...&lt;BR /&gt;
Thank you so much. I will attemp to incorporate this new code and&lt;BR /&gt;
information into my routine.&lt;BR /&gt;
Thanks again for all your help.  When complete, this will save a tremendous&lt;BR /&gt;
amount of rework.&lt;BR /&gt;
&lt;BR /&gt;
Dan&lt;BR /&gt;
&lt;BR /&gt;
"Paul Richardson" &lt;PRICHARDSONATADELPHIA.NET&gt; wrote in message&lt;BR /&gt;
news:5213115@discussion.autodesk.com...&lt;BR /&gt;
The nice thing is you don't have to know what is going in the sort&lt;BR /&gt;
methods, just that it returns a sorted something for now...&lt;BR /&gt;
&lt;BR /&gt;
That being said, here is code to add the x and y insertion coords to a 2d&lt;BR /&gt;
array,&lt;BR /&gt;
and then relate a sorted 2d array of insertion points back to entities in&lt;BR /&gt;
your selection set.&lt;BR /&gt;
&lt;BR /&gt;
You need a function to sort 2d arrays...google "Sort 2d coordinates" or such&lt;BR /&gt;
&lt;BR /&gt;
[code]&lt;BR /&gt;
 Sub Stub()&lt;BR /&gt;
  Dim SS As AcadSelectionSet&lt;BR /&gt;
  Dim filType(0) As Integer&lt;BR /&gt;
  Dim filData(0)&lt;BR /&gt;
  'filter data for TEXT&lt;BR /&gt;
  filType(0) = 0&lt;BR /&gt;
  filData(0) = "TEXT"&lt;BR /&gt;
&lt;BR /&gt;
  Set SS = SSAdd("test")&lt;BR /&gt;
  SS.SelectOnScreen filType, filData&lt;BR /&gt;
  'create 2d array (x,y) same size as your SS&lt;BR /&gt;
  ReDim coords(SS.Count - 1, 1)&lt;BR /&gt;
&lt;BR /&gt;
  Dim txtEnt As AcadText&lt;BR /&gt;
  Dim i As Integer&lt;BR /&gt;
&lt;BR /&gt;
  For i = 0 To SS.Count - 1&lt;BR /&gt;
    Set txtEnt = SS(i)&lt;BR /&gt;
    coords(i, 0) = txtEnt.InsertionPoint(0)&lt;BR /&gt;
    coords(i, 1) = txtEnt.InsertionPoint(1)&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  'now you have an array of 2d coordinates, do&lt;BR /&gt;
  'a google for a function that will sort 2d&lt;BR /&gt;
  'coordinate arrays.&lt;BR /&gt;
&lt;BR /&gt;
  Dim j As Integer&lt;BR /&gt;
 'relate sorted coords back to your SS ents&lt;BR /&gt;
 'doesn't consider duplicate insertion points&lt;BR /&gt;
  For i = LBound(coords) To UBound(coords)&lt;BR /&gt;
    For j = 0 To SS.Count - 1&lt;BR /&gt;
      Set txtEnt = SS(j)&lt;BR /&gt;
      If txtEnt.InsertionPoint(0) = coords(i, 0) And _&lt;BR /&gt;
          txtEnt.InsertionPoint(1) = coords(i, 1) Then&lt;BR /&gt;
          'add text value to your table&lt;BR /&gt;
          Exit For&lt;BR /&gt;
      End If&lt;BR /&gt;
    Next j&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  Call SSRemove("test")&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Function SSAdd(inName As String) As AcadSelectionSet&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  With ThisDrawing&lt;BR /&gt;
    .SelectionSets(inName).Delete&lt;BR /&gt;
    Set SSAdd = .SelectionSets.Add(inName)&lt;BR /&gt;
  End With&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Sub SSRemove(inName As String)&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  ThisDrawing.SelectionSets(inName).Delete&lt;BR /&gt;
End Sub&lt;BR /&gt;
[/code]&lt;BR /&gt;
&lt;BR /&gt;
"Dan" &lt;DANDERSON&gt; wrote in message&lt;BR /&gt;
news:5213024@discussion.autodesk.com...&lt;BR /&gt;
I really do not understand most of what is happening in the heap sort&lt;BR /&gt;
method, but I will learn it. I appreciate all the help.  This code is much&lt;BR /&gt;
more advanced than I have ever written.  I was hoping to learn some new&lt;BR /&gt;
tricks, but found a whole new area of coding I can explore.&lt;BR /&gt;
&lt;BR /&gt;
Thanks again,&lt;BR /&gt;
Dan&lt;/DANDERSON&gt;&lt;/PRICHARDSONATADELPHIA.NET&gt;&lt;/DANDERSON&gt;&lt;/PRICHARDSONATADELPHIA.NET&gt;&lt;/PRICHARDSONATADELPHIA.NET&gt;&lt;/PRICHARDSONATADELPHIA.NET&gt;&lt;/DANDERSON&gt;</description>
      <pubDate>Wed, 21 Jun 2006 15:34:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680037#M33446</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-21T15:34:39Z</dc:date>
    </item>
    <item>
      <title>Re: Sort an array of text objects Asc by their X and Y insertion point  values</title>
      <link>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680038#M33447</link>
      <description>I saw the drawing. I gave you code to sort via dictionary, or collection.&lt;BR /&gt;
You need to figure out the double sort; most of us are long past the &lt;BR /&gt;
recursion&lt;BR /&gt;
semester... your turn.:) Not that recursion is the only way to go.&lt;BR /&gt;
&lt;BR /&gt;
How about an easy way out. Use Excel model to sort by Column1(x) and&lt;BR /&gt;
then by Column2(Y).&lt;BR /&gt;
&lt;BR /&gt;
Use the idea I sent creating a multiple dimension array...&lt;BR /&gt;
ReDim arr(ss.Count - 1, 2)&lt;BR /&gt;
(X Y Handle)&lt;BR /&gt;
&lt;BR /&gt;
Now let Excel sort for you and then use the handle (column3) to get back to &lt;BR /&gt;
your&lt;BR /&gt;
entity.&lt;BR /&gt;
&lt;BR /&gt;
"Dan" &lt;DANDERSON&gt; wrote in message &lt;BR /&gt;
news:5213900@discussion.autodesk.com...&lt;BR /&gt;
Did you have an opportunity to view my example drawing?  I have 1000's of&lt;BR /&gt;
files with this configuration, I am trying to update.&lt;BR /&gt;
Fatty was kind enough to assist me with the initial code, but I am still&lt;BR /&gt;
hung up on the sorting.  Did you have an opportunity to run the existing&lt;BR /&gt;
code? If you select the text object individually, in order, the code works&lt;BR /&gt;
great, but when I have 164 entities, this will be to tedious, and time&lt;BR /&gt;
consuming.&lt;BR /&gt;
&lt;BR /&gt;
Once again, I appreciate your time and efforts.&lt;BR /&gt;
&lt;BR /&gt;
Dan&lt;BR /&gt;
&lt;BR /&gt;
"Dan" &lt;DANDERSON&gt; wrote in message&lt;BR /&gt;
news:5213872@discussion.autodesk.com...&lt;BR /&gt;
Thank you, I will try to read more. I am a newbie at VBA, and this sorting&lt;BR /&gt;
algorithun code is really unfamiliar to me.&lt;BR /&gt;
&lt;BR /&gt;
"Paul Richardson" &lt;PRICHARDSONATADELPHIA.NET&gt; wrote in message&lt;BR /&gt;
news:5213519@discussion.autodesk.com...&lt;BR /&gt;
check out this link, it's in c but should give you&lt;BR /&gt;
some ideas...&lt;BR /&gt;
http://www.cedarcreek.umn.edu/tools/declare/sort.d.pdf&lt;BR /&gt;
&lt;BR /&gt;
"Paul Richardson" &lt;PRICHARDSONATADELPHIA.NET&gt; wrote in message&lt;BR /&gt;
news:5213243@discussion.autodesk.com...&lt;BR /&gt;
you need to reference the "microsoft scripting runtime" but the&lt;BR /&gt;
idea doesn't work anyway...I should have tired it first..&lt;BR /&gt;
&lt;BR /&gt;
"Paul Richardson" &lt;PRICHARDSONATADELPHIA.NET&gt; wrote in message&lt;BR /&gt;
news:5213225@discussion.autodesk.com...&lt;BR /&gt;
Here ya go...Very simple I just subtracted the Y insertion&lt;BR /&gt;
point from the X insertion point and used the difference to&lt;BR /&gt;
sort.&lt;BR /&gt;
&lt;BR /&gt;
[code]&lt;BR /&gt;
Option Explicit&lt;BR /&gt;
Const dictKey = 1&lt;BR /&gt;
Const dictItem = 2&lt;BR /&gt;
&lt;BR /&gt;
 Sub Stub()&lt;BR /&gt;
  Dim SS As AcadSelectionSet&lt;BR /&gt;
  Dim filType(0) As Integer&lt;BR /&gt;
  Dim filData(0)&lt;BR /&gt;
  filType(0) = 0&lt;BR /&gt;
  filData(0) = "TEXT"&lt;BR /&gt;
&lt;BR /&gt;
  Set SS = SSAdd("test")&lt;BR /&gt;
  SS.SelectOnScreen filType, filData&lt;BR /&gt;
&lt;BR /&gt;
  Dim Dict As Scripting.Dictionary&lt;BR /&gt;
  Set Dict = SSToDictionary(SS)&lt;BR /&gt;
  SortDictionary Dict, dictItem&lt;BR /&gt;
&lt;BR /&gt;
  'iterate sorted collection use Dict.Key to get&lt;BR /&gt;
  'the ents.&lt;BR /&gt;
  Dim i As Integer&lt;BR /&gt;
  Dim txt As AcadText&lt;BR /&gt;
  For i = 0 To Dict.Count - 1&lt;BR /&gt;
    Set txt = ThisDrawing.HandleToObject(Dict.Keys(i))&lt;BR /&gt;
    txt.TextString = i 'test only remove&lt;BR /&gt;
    'add to your table&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  Call SSRemove("test")&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
'Add ss ents to Dictionary using ent.handle as key and ents&lt;BR /&gt;
'(xIns - yIns) as item.&lt;BR /&gt;
Function SSToDictionary(inSS As AcadSelectionSet) As Scripting.Dictionary&lt;BR /&gt;
  Dim i As Integer&lt;BR /&gt;
&lt;BR /&gt;
  Dim txt As AcadText&lt;BR /&gt;
  Dim Dict As New Scripting.Dictionary&lt;BR /&gt;
&lt;BR /&gt;
  For i = 0 To inSS.Count - 1&lt;BR /&gt;
    Set txt = inSS(i)&lt;BR /&gt;
     Dict.Add txt.Handle, _&lt;BR /&gt;
      (VBA.Round((CStr(txt.InsertionPoint(0) - txt.InsertionPoint(1))), 2))&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  Set SSToDictionary = Dict&lt;BR /&gt;
&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Function SSAdd(inName As String) As AcadSelectionSet&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  With ThisDrawing&lt;BR /&gt;
    .SelectionSets(inName).Delete&lt;BR /&gt;
    Set SSAdd = .SelectionSets.Add(inName)&lt;BR /&gt;
  End With&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Sub SSRemove(inName As String)&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  ThisDrawing.SelectionSets(inName).Delete&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
'Modified MSDN Function&lt;BR /&gt;
Function SortDictionary(objDict, intSort)&lt;BR /&gt;
  ' declare our variables&lt;BR /&gt;
  Dim Dict()&lt;BR /&gt;
  Dim objKey&lt;BR /&gt;
  Dim strKey, strItem&lt;BR /&gt;
  Dim X, Y, Z&lt;BR /&gt;
&lt;BR /&gt;
  ' get the dictionary count&lt;BR /&gt;
  Z = objDict.Count&lt;BR /&gt;
&lt;BR /&gt;
  ' we need more than one item to warrant sorting&lt;BR /&gt;
  If Z &amp;gt; 1 Then&lt;BR /&gt;
    ' create an array to store dictionary information&lt;BR /&gt;
    ReDim Dict(Z, 2)&lt;BR /&gt;
    X = 0&lt;BR /&gt;
    ' populate the array&lt;BR /&gt;
    For Each objKey In objDict&lt;BR /&gt;
        Dict(X, dictKey) = (objKey)&lt;BR /&gt;
        Dict(X, dictItem) = (objDict(objKey))&lt;BR /&gt;
        X = X + 1&lt;BR /&gt;
    Next&lt;BR /&gt;
&lt;BR /&gt;
    ' perform a a shell sort of the string array&lt;BR /&gt;
    For X = 0 To (Z - 2)&lt;BR /&gt;
      For Y = X To (Z - 1)&lt;BR /&gt;
        If Dict(X, intSort) &amp;gt; Dict(Y, intSort) Then&lt;BR /&gt;
            strKey = Dict(X, dictKey)&lt;BR /&gt;
            strItem = Dict(X, dictItem)&lt;BR /&gt;
            Dict(X, dictKey) = Dict(Y, dictKey)&lt;BR /&gt;
            Dict(X, dictItem) = Dict(Y, dictItem)&lt;BR /&gt;
            Dict(Y, dictKey) = strKey&lt;BR /&gt;
            Dict(Y, dictItem) = strItem&lt;BR /&gt;
        End If&lt;BR /&gt;
      Next&lt;BR /&gt;
    Next&lt;BR /&gt;
&lt;BR /&gt;
    ' erase the contents of the dictionary object&lt;BR /&gt;
    objDict.RemoveAll&lt;BR /&gt;
&lt;BR /&gt;
    ' repopulate the dictionary with the sorted information&lt;BR /&gt;
    For X = 0 To (Z - 1)&lt;BR /&gt;
      objDict.Add Dict(X, dictKey), Dict(X, dictItem)&lt;BR /&gt;
    Next&lt;BR /&gt;
&lt;BR /&gt;
  End If&lt;BR /&gt;
&lt;BR /&gt;
End Function&lt;BR /&gt;
[/code]&lt;BR /&gt;
&lt;BR /&gt;
"Dan" &lt;DANDERSON&gt; wrote in message&lt;BR /&gt;
news:5213107@discussion.autodesk.com...&lt;BR /&gt;
Thank you so much. I will attemp to incorporate this new code and&lt;BR /&gt;
information into my routine.&lt;BR /&gt;
Thanks again for all your help.  When complete, this will save a tremendous&lt;BR /&gt;
amount of rework.&lt;BR /&gt;
&lt;BR /&gt;
Dan&lt;BR /&gt;
&lt;BR /&gt;
"Paul Richardson" &lt;PRICHARDSONATADELPHIA.NET&gt; wrote in message&lt;BR /&gt;
news:5213115@discussion.autodesk.com...&lt;BR /&gt;
The nice thing is you don't have to know what is going in the sort&lt;BR /&gt;
methods, just that it returns a sorted something for now...&lt;BR /&gt;
&lt;BR /&gt;
That being said, here is code to add the x and y insertion coords to a 2d&lt;BR /&gt;
array,&lt;BR /&gt;
and then relate a sorted 2d array of insertion points back to entities in&lt;BR /&gt;
your selection set.&lt;BR /&gt;
&lt;BR /&gt;
You need a function to sort 2d arrays...google "Sort 2d coordinates" or such&lt;BR /&gt;
&lt;BR /&gt;
[code]&lt;BR /&gt;
 Sub Stub()&lt;BR /&gt;
  Dim SS As AcadSelectionSet&lt;BR /&gt;
  Dim filType(0) As Integer&lt;BR /&gt;
  Dim filData(0)&lt;BR /&gt;
  'filter data for TEXT&lt;BR /&gt;
  filType(0) = 0&lt;BR /&gt;
  filData(0) = "TEXT"&lt;BR /&gt;
&lt;BR /&gt;
  Set SS = SSAdd("test")&lt;BR /&gt;
  SS.SelectOnScreen filType, filData&lt;BR /&gt;
  'create 2d array (x,y) same size as your SS&lt;BR /&gt;
  ReDim coords(SS.Count - 1, 1)&lt;BR /&gt;
&lt;BR /&gt;
  Dim txtEnt As AcadText&lt;BR /&gt;
  Dim i As Integer&lt;BR /&gt;
&lt;BR /&gt;
  For i = 0 To SS.Count - 1&lt;BR /&gt;
    Set txtEnt = SS(i)&lt;BR /&gt;
    coords(i, 0) = txtEnt.InsertionPoint(0)&lt;BR /&gt;
    coords(i, 1) = txtEnt.InsertionPoint(1)&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  'now you have an array of 2d coordinates, do&lt;BR /&gt;
  'a google for a function that will sort 2d&lt;BR /&gt;
  'coordinate arrays.&lt;BR /&gt;
&lt;BR /&gt;
  Dim j As Integer&lt;BR /&gt;
 'relate sorted coords back to your SS ents&lt;BR /&gt;
 'doesn't consider duplicate insertion points&lt;BR /&gt;
  For i = LBound(coords) To UBound(coords)&lt;BR /&gt;
    For j = 0 To SS.Count - 1&lt;BR /&gt;
      Set txtEnt = SS(j)&lt;BR /&gt;
      If txtEnt.InsertionPoint(0) = coords(i, 0) And _&lt;BR /&gt;
          txtEnt.InsertionPoint(1) = coords(i, 1) Then&lt;BR /&gt;
          'add text value to your table&lt;BR /&gt;
          Exit For&lt;BR /&gt;
      End If&lt;BR /&gt;
    Next j&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  Call SSRemove("test")&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Function SSAdd(inName As String) As AcadSelectionSet&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  With ThisDrawing&lt;BR /&gt;
    .SelectionSets(inName).Delete&lt;BR /&gt;
    Set SSAdd = .SelectionSets.Add(inName)&lt;BR /&gt;
  End With&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Sub SSRemove(inName As String)&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  ThisDrawing.SelectionSets(inName).Delete&lt;BR /&gt;
End Sub&lt;BR /&gt;
[/code]&lt;BR /&gt;
&lt;BR /&gt;
"Dan" &lt;DANDERSON&gt; wrote in message&lt;BR /&gt;
news:5213024@discussion.autodesk.com...&lt;BR /&gt;
I really do not understand most of what is happening in the heap sort&lt;BR /&gt;
method, but I will learn it. I appreciate all the help.  This code is much&lt;BR /&gt;
more advanced than I have ever written.  I was hoping to learn some new&lt;BR /&gt;
tricks, but found a whole new area of coding I can explore.&lt;BR /&gt;
&lt;BR /&gt;
Thanks again,&lt;BR /&gt;
Dan&lt;/DANDERSON&gt;&lt;/PRICHARDSONATADELPHIA.NET&gt;&lt;/DANDERSON&gt;&lt;/PRICHARDSONATADELPHIA.NET&gt;&lt;/PRICHARDSONATADELPHIA.NET&gt;&lt;/PRICHARDSONATADELPHIA.NET&gt;&lt;/DANDERSON&gt;&lt;/DANDERSON&gt;</description>
      <pubDate>Wed, 21 Jun 2006 15:53:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680038#M33447</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-21T15:53:56Z</dc:date>
    </item>
    <item>
      <title>Re: Sort an array of text objects Asc by their X and Y insertion point  values</title>
      <link>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680039#M33448</link>
      <description>Thank you for your efforts and time. I appreciate it.&lt;BR /&gt;
I do not understand your examples to begin with, so it is hard to use ideas &lt;BR /&gt;
and principles from the various code you have provided.&lt;BR /&gt;
I am self taught at VBA, and rarely given any time to code new routines with &lt;BR /&gt;
my drafting schedule.&lt;BR /&gt;
I can and do respect your intentions to help, and teach me, but I am really &lt;BR /&gt;
clueless about working with arrays.&lt;BR /&gt;
I have thought about the easy way out by using Excel. Wouldn't it be much &lt;BR /&gt;
slower?&lt;BR /&gt;
What did you mean by "use the handle (column3) to get back to your entity."?&lt;BR /&gt;
Is this the object ID?&lt;BR /&gt;
BTW, if you use my current code, do you have a clue why the table updates so &lt;BR /&gt;
slowly?&lt;BR /&gt;
&lt;BR /&gt;
I am reading up on arrays right now.  The developer help isn't much help in &lt;BR /&gt;
this area that I can see.&lt;BR /&gt;
&lt;BR /&gt;
Dan&lt;BR /&gt;
&lt;BR /&gt;
"Paul Richardson" &lt;PRICHARDSONATADELPHIA.NET&gt; wrote in message &lt;BR /&gt;
news:5213930@discussion.autodesk.com...&lt;BR /&gt;
I saw the drawing. I gave you code to sort via dictionary, or collection.&lt;BR /&gt;
You need to figure out the double sort; most of us are long past the&lt;BR /&gt;
recursion&lt;BR /&gt;
semester... your turn.:) Not that recursion is the only way to go.&lt;BR /&gt;
&lt;BR /&gt;
How about an easy way out. Use Excel model to sort by Column1(x) and&lt;BR /&gt;
then by Column2(Y).&lt;BR /&gt;
&lt;BR /&gt;
Use the idea I sent creating a multiple dimension array...&lt;BR /&gt;
ReDim arr(ss.Count - 1, 2)&lt;BR /&gt;
(X Y Handle)&lt;BR /&gt;
&lt;BR /&gt;
Now let Excel sort for you and then use the handle (column3) to get back to&lt;BR /&gt;
your&lt;BR /&gt;
entity.&lt;BR /&gt;
&lt;BR /&gt;
"Dan" &lt;DANDERSON&gt; wrote in message&lt;BR /&gt;
news:5213900@discussion.autodesk.com...&lt;BR /&gt;
Did you have an opportunity to view my example drawing?  I have 1000's of&lt;BR /&gt;
files with this configuration, I am trying to update.&lt;BR /&gt;
Fatty was kind enough to assist me with the initial code, but I am still&lt;BR /&gt;
hung up on the sorting.  Did you have an opportunity to run the existing&lt;BR /&gt;
code? If you select the text object individually, in order, the code works&lt;BR /&gt;
great, but when I have 164 entities, this will be to tedious, and time&lt;BR /&gt;
consuming.&lt;BR /&gt;
&lt;BR /&gt;
Once again, I appreciate your time and efforts.&lt;BR /&gt;
&lt;BR /&gt;
Dan&lt;BR /&gt;
&lt;BR /&gt;
"Dan" &lt;DANDERSON&gt; wrote in message&lt;BR /&gt;
news:5213872@discussion.autodesk.com...&lt;BR /&gt;
Thank you, I will try to read more. I am a newbie at VBA, and this sorting&lt;BR /&gt;
algorithun code is really unfamiliar to me.&lt;BR /&gt;
&lt;BR /&gt;
"Paul Richardson" &lt;PRICHARDSONATADELPHIA.NET&gt; wrote in message&lt;BR /&gt;
news:5213519@discussion.autodesk.com...&lt;BR /&gt;
check out this link, it's in c but should give you&lt;BR /&gt;
some ideas...&lt;BR /&gt;
http://www.cedarcreek.umn.edu/tools/declare/sort.d.pdf&lt;BR /&gt;
&lt;BR /&gt;
"Paul Richardson" &lt;PRICHARDSONATADELPHIA.NET&gt; wrote in message&lt;BR /&gt;
news:5213243@discussion.autodesk.com...&lt;BR /&gt;
you need to reference the "microsoft scripting runtime" but the&lt;BR /&gt;
idea doesn't work anyway...I should have tired it first..&lt;BR /&gt;
&lt;BR /&gt;
"Paul Richardson" &lt;PRICHARDSONATADELPHIA.NET&gt; wrote in message&lt;BR /&gt;
news:5213225@discussion.autodesk.com...&lt;BR /&gt;
Here ya go...Very simple I just subtracted the Y insertion&lt;BR /&gt;
point from the X insertion point and used the difference to&lt;BR /&gt;
sort.&lt;BR /&gt;
&lt;BR /&gt;
[code]&lt;BR /&gt;
Option Explicit&lt;BR /&gt;
Const dictKey = 1&lt;BR /&gt;
Const dictItem = 2&lt;BR /&gt;
&lt;BR /&gt;
 Sub Stub()&lt;BR /&gt;
  Dim SS As AcadSelectionSet&lt;BR /&gt;
  Dim filType(0) As Integer&lt;BR /&gt;
  Dim filData(0)&lt;BR /&gt;
  filType(0) = 0&lt;BR /&gt;
  filData(0) = "TEXT"&lt;BR /&gt;
&lt;BR /&gt;
  Set SS = SSAdd("test")&lt;BR /&gt;
  SS.SelectOnScreen filType, filData&lt;BR /&gt;
&lt;BR /&gt;
  Dim Dict As Scripting.Dictionary&lt;BR /&gt;
  Set Dict = SSToDictionary(SS)&lt;BR /&gt;
  SortDictionary Dict, dictItem&lt;BR /&gt;
&lt;BR /&gt;
  'iterate sorted collection use Dict.Key to get&lt;BR /&gt;
  'the ents.&lt;BR /&gt;
  Dim i As Integer&lt;BR /&gt;
  Dim txt As AcadText&lt;BR /&gt;
  For i = 0 To Dict.Count - 1&lt;BR /&gt;
    Set txt = ThisDrawing.HandleToObject(Dict.Keys(i))&lt;BR /&gt;
    txt.TextString = i 'test only remove&lt;BR /&gt;
    'add to your table&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  Call SSRemove("test")&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
'Add ss ents to Dictionary using ent.handle as key and ents&lt;BR /&gt;
'(xIns - yIns) as item.&lt;BR /&gt;
Function SSToDictionary(inSS As AcadSelectionSet) As Scripting.Dictionary&lt;BR /&gt;
  Dim i As Integer&lt;BR /&gt;
&lt;BR /&gt;
  Dim txt As AcadText&lt;BR /&gt;
  Dim Dict As New Scripting.Dictionary&lt;BR /&gt;
&lt;BR /&gt;
  For i = 0 To inSS.Count - 1&lt;BR /&gt;
    Set txt = inSS(i)&lt;BR /&gt;
     Dict.Add txt.Handle, _&lt;BR /&gt;
      (VBA.Round((CStr(txt.InsertionPoint(0) - txt.InsertionPoint(1))), 2))&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  Set SSToDictionary = Dict&lt;BR /&gt;
&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Function SSAdd(inName As String) As AcadSelectionSet&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  With ThisDrawing&lt;BR /&gt;
    .SelectionSets(inName).Delete&lt;BR /&gt;
    Set SSAdd = .SelectionSets.Add(inName)&lt;BR /&gt;
  End With&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Sub SSRemove(inName As String)&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  ThisDrawing.SelectionSets(inName).Delete&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
'Modified MSDN Function&lt;BR /&gt;
Function SortDictionary(objDict, intSort)&lt;BR /&gt;
  ' declare our variables&lt;BR /&gt;
  Dim Dict()&lt;BR /&gt;
  Dim objKey&lt;BR /&gt;
  Dim strKey, strItem&lt;BR /&gt;
  Dim X, Y, Z&lt;BR /&gt;
&lt;BR /&gt;
  ' get the dictionary count&lt;BR /&gt;
  Z = objDict.Count&lt;BR /&gt;
&lt;BR /&gt;
  ' we need more than one item to warrant sorting&lt;BR /&gt;
  If Z &amp;gt; 1 Then&lt;BR /&gt;
    ' create an array to store dictionary information&lt;BR /&gt;
    ReDim Dict(Z, 2)&lt;BR /&gt;
    X = 0&lt;BR /&gt;
    ' populate the array&lt;BR /&gt;
    For Each objKey In objDict&lt;BR /&gt;
        Dict(X, dictKey) = (objKey)&lt;BR /&gt;
        Dict(X, dictItem) = (objDict(objKey))&lt;BR /&gt;
        X = X + 1&lt;BR /&gt;
    Next&lt;BR /&gt;
&lt;BR /&gt;
    ' perform a a shell sort of the string array&lt;BR /&gt;
    For X = 0 To (Z - 2)&lt;BR /&gt;
      For Y = X To (Z - 1)&lt;BR /&gt;
        If Dict(X, intSort) &amp;gt; Dict(Y, intSort) Then&lt;BR /&gt;
            strKey = Dict(X, dictKey)&lt;BR /&gt;
            strItem = Dict(X, dictItem)&lt;BR /&gt;
            Dict(X, dictKey) = Dict(Y, dictKey)&lt;BR /&gt;
            Dict(X, dictItem) = Dict(Y, dictItem)&lt;BR /&gt;
            Dict(Y, dictKey) = strKey&lt;BR /&gt;
            Dict(Y, dictItem) = strItem&lt;BR /&gt;
        End If&lt;BR /&gt;
      Next&lt;BR /&gt;
    Next&lt;BR /&gt;
&lt;BR /&gt;
    ' erase the contents of the dictionary object&lt;BR /&gt;
    objDict.RemoveAll&lt;BR /&gt;
&lt;BR /&gt;
    ' repopulate the dictionary with the sorted information&lt;BR /&gt;
    For X = 0 To (Z - 1)&lt;BR /&gt;
      objDict.Add Dict(X, dictKey), Dict(X, dictItem)&lt;BR /&gt;
    Next&lt;BR /&gt;
&lt;BR /&gt;
  End If&lt;BR /&gt;
&lt;BR /&gt;
End Function&lt;BR /&gt;
[/code]&lt;BR /&gt;
&lt;BR /&gt;
"Dan" &lt;DANDERSON&gt; wrote in message&lt;BR /&gt;
news:5213107@discussion.autodesk.com...&lt;BR /&gt;
Thank you so much. I will attemp to incorporate this new code and&lt;BR /&gt;
information into my routine.&lt;BR /&gt;
Thanks again for all your help.  When complete, this will save a tremendous&lt;BR /&gt;
amount of rework.&lt;BR /&gt;
&lt;BR /&gt;
Dan&lt;BR /&gt;
&lt;BR /&gt;
"Paul Richardson" &lt;PRICHARDSONATADELPHIA.NET&gt; wrote in message&lt;BR /&gt;
news:5213115@discussion.autodesk.com...&lt;BR /&gt;
The nice thing is you don't have to know what is going in the sort&lt;BR /&gt;
methods, just that it returns a sorted something for now...&lt;BR /&gt;
&lt;BR /&gt;
That being said, here is code to add the x and y insertion coords to a 2d&lt;BR /&gt;
array,&lt;BR /&gt;
and then relate a sorted 2d array of insertion points back to entities in&lt;BR /&gt;
your selection set.&lt;BR /&gt;
&lt;BR /&gt;
You need a function to sort 2d arrays...google "Sort 2d coordinates" or such&lt;BR /&gt;
&lt;BR /&gt;
[code]&lt;BR /&gt;
 Sub Stub()&lt;BR /&gt;
  Dim SS As AcadSelectionSet&lt;BR /&gt;
  Dim filType(0) As Integer&lt;BR /&gt;
  Dim filData(0)&lt;BR /&gt;
  'filter data for TEXT&lt;BR /&gt;
  filType(0) = 0&lt;BR /&gt;
  filData(0) = "TEXT"&lt;BR /&gt;
&lt;BR /&gt;
  Set SS = SSAdd("test")&lt;BR /&gt;
  SS.SelectOnScreen filType, filData&lt;BR /&gt;
  'create 2d array (x,y) same size as your SS&lt;BR /&gt;
  ReDim coords(SS.Count - 1, 1)&lt;BR /&gt;
&lt;BR /&gt;
  Dim txtEnt As AcadText&lt;BR /&gt;
  Dim i As Integer&lt;BR /&gt;
&lt;BR /&gt;
  For i = 0 To SS.Count - 1&lt;BR /&gt;
    Set txtEnt = SS(i)&lt;BR /&gt;
    coords(i, 0) = txtEnt.InsertionPoint(0)&lt;BR /&gt;
    coords(i, 1) = txtEnt.InsertionPoint(1)&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  'now you have an array of 2d coordinates, do&lt;BR /&gt;
  'a google for a function that will sort 2d&lt;BR /&gt;
  'coordinate arrays.&lt;BR /&gt;
&lt;BR /&gt;
  Dim j As Integer&lt;BR /&gt;
 'relate sorted coords back to your SS ents&lt;BR /&gt;
 'doesn't consider duplicate insertion points&lt;BR /&gt;
  For i = LBound(coords) To UBound(coords)&lt;BR /&gt;
    For j = 0 To SS.Count - 1&lt;BR /&gt;
      Set txtEnt = SS(j)&lt;BR /&gt;
      If txtEnt.InsertionPoint(0) = coords(i, 0) And _&lt;BR /&gt;
          txtEnt.InsertionPoint(1) = coords(i, 1) Then&lt;BR /&gt;
          'add text value to your table&lt;BR /&gt;
          Exit For&lt;BR /&gt;
      End If&lt;BR /&gt;
    Next j&lt;BR /&gt;
  Next i&lt;BR /&gt;
&lt;BR /&gt;
  Call SSRemove("test")&lt;BR /&gt;
&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Function SSAdd(inName As String) As AcadSelectionSet&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  With ThisDrawing&lt;BR /&gt;
    .SelectionSets(inName).Delete&lt;BR /&gt;
    Set SSAdd = .SelectionSets.Add(inName)&lt;BR /&gt;
  End With&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
Sub SSRemove(inName As String)&lt;BR /&gt;
  On Error Resume Next&lt;BR /&gt;
  ThisDrawing.SelectionSets(inName).Delete&lt;BR /&gt;
End Sub&lt;BR /&gt;
[/code]&lt;BR /&gt;
&lt;BR /&gt;
"Dan" &lt;DANDERSON&gt; wrote in message&lt;BR /&gt;
news:5213024@discussion.autodesk.com...&lt;BR /&gt;
I really do not understand most of what is happening in the heap sort&lt;BR /&gt;
method, but I will learn it. I appreciate all the help.  This code is much&lt;BR /&gt;
more advanced than I have ever written.  I was hoping to learn some new&lt;BR /&gt;
tricks, but found a whole new area of coding I can explore.&lt;BR /&gt;
&lt;BR /&gt;
Thanks again,&lt;BR /&gt;
Dan&lt;/DANDERSON&gt;&lt;/PRICHARDSONATADELPHIA.NET&gt;&lt;/DANDERSON&gt;&lt;/PRICHARDSONATADELPHIA.NET&gt;&lt;/PRICHARDSONATADELPHIA.NET&gt;&lt;/PRICHARDSONATADELPHIA.NET&gt;&lt;/DANDERSON&gt;&lt;/DANDERSON&gt;&lt;/PRICHARDSONATADELPHIA.NET&gt;</description>
      <pubDate>Wed, 21 Jun 2006 16:59:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/sort-an-array-of-text-objects-asc-by-their-x-and-y-insertion/m-p/1680039#M33448</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-06-21T16:59:31Z</dc:date>
    </item>
  </channel>
</rss>

