Werner Check-out the $QUERY, $QSUBSCRIPT and $QLENGTH functions.
They may help. Regards Sukesh Dipl.-Ing. Werner Riegler <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hi, > > who knows how to simple sort integer arrays with cache > > > I found the $ORDER function, > but it "only" sorts the index and not the content of the array > so if I have entries with the same value I miss them after sorting ... > > I had a sorting function in PHP like this: > asort($p, SORT_NUMERIC); > > now I have: > > set Cnt = object.ObjectCollection.Count() > for oc=1:1:Cnt > { > // p1 is an integer value...(parameter values of objects referenced in a > collection...) > set Data(p1) = oc > } > set key = $Order(Data("")) // ,-1 ??? > > While (key '= "") { > if (' Silent) Write key," - ", idx," - ",Data(key),! > Set sortedIndex(idx) = Data(key) > set idx = idx + 1 > Set key = $Order(Data(key)) // next subscript > } > > for oc=1:1:Cnt > { > if (' Silent) { > w "oc ",oc, ! > w "sortedIndex(oc) - " , sortedIndex(oc),! > } > ... > } > > or more simple: > set a(1) = 6 > set a(2) = 4 > set a(3) = 3 > set a(4) = 1 > set a(5) = 3 > and so on...and I would like/need a sorted array so that I know the indices > and the content like: > b(1) = a(4) = 1 > b(2) = a(3) = 3 > b(3) = a(5) = 3 > b(4) = a(2) = 4 > b(5) = a(1) = 6 > > it took a while until I rec. that the index and not the content is sortet > ... > > so I tried to switch index and content and now I am missing entries in the > result ... > > what have I missed in searchin the docu ? > > please help ! > > brg > > werner > >
