View Full Version : Array sorting
Glenn Hickman
8-Feb-2006, 06:52 AM
Hi,
Can anybody help sorting an array of integers, we are trying the following
command but it is still sorting it alphanumerically
send sort_items to myarray descending
Thanks,
Glenn Hickman.
Marco
8-Feb-2006, 10:33 PM
Hi Glenn,
I believe that dataflex 'workes out' the data type as you enter the
information. You must have somehow saved one or more values that it
regarded as strings. Perhaps direct from the screen etc.
If you make sure that you move all values with the integer funtion.
Set Array_Value Item 10 To (Integer(Screen10.1))
Cheers,
Marco
Glenn Hickman wrote:
> Hi,
>
> Can anybody help sorting an array of integers, we are trying the following
> command but it is still sorting it alphanumerically
>
> send sort_items to myarray descending
>
> Thanks,
> Glenn Hickman.
>
>
starzen
12-Feb-2006, 09:45 AM
Glenn
because you mention sort_items i guess you are talking about the array class
not about the new array data type
If you are using the array class the data type is always string and therfor
sorting will be string sorting
for example the numbers 1, 3, 10, 11, 13
would be sorted as
1
10
11
13
3
in order to sort them in numeric order you would have to prefix them with
leading zero's
0001
0003
0010
0011
0013
or you could use the new array data type
--
Michael Salzlechner
StarZen Technologies, Inc
http://www.starzen.com
DataFlex Addon products, consulting
Vincent Oorsprong
12-Feb-2006, 12:50 PM
Mike,
That is only true when using SET VALUE. If you use SET ARRAY_VALUE
passing integer values the values are stored as integer and sorted as such.
See enclosed source code;
--
Regards,
Vincent Oorsprong
Data Access Europe B.V.
http://www.dataaccess.nl
use ui
integer iItem
string sKey 1
object otest is an array
set array_value item 0 to 3
set array_value item 1 to 13
set array_value item 2 to 11
set array_value item 3 to 10
set array_value item 4 to 1
end_object
for iItem from 0 to 4
show (value (oTest (current_Object), iItem)) ', '
loop
showln
send sort_items to (otest (current_object))
for iItem from 0 to 4
show (value (oTest (current_Object), iItem)) ', '
loop
showln
object otest2 is an array
set value item 0 to 3
set value item 1 to 13
set value item 2 to 11
set value item 3 to 10
set value item 4 to 1
end_object
for iItem from 0 to 4
show (value (oTest2 (current_Object), iItem)) ', '
loop
showln
send sort_items to (otest2 (current_object))
for iItem from 0 to 4
show (value (oTest2 (current_Object), iItem)) ', '
loop
showln
inkey sKey
Chris Spencer
13-Feb-2006, 02:39 PM
Vincent
FYI Array_Value is not documented in the help for methods for array class
Chris Spencer
TUFware Systems
"Vincent Oorsprong" <vincent.oorsprong@reply.at.newsgroup.nl> wrote in
message news:SgvpMz$LGHA.3548@dacmail.dataaccess.com...
> Mike,
>
> That is only true when using SET VALUE. If you use SET ARRAY_VALUE
> passing integer values the values are stored as integer and sorted as
> such.
>
> See enclosed source code;
> --
> Regards,
> Vincent Oorsprong
> Data Access Europe B.V.
> http://www.dataaccess.nl
>
--------------------------------------------------------------------------------
> use ui
>
> integer iItem
> string sKey 1
>
> object otest is an array
> set array_value item 0 to 3
> set array_value item 1 to 13
> set array_value item 2 to 11
> set array_value item 3 to 10
> set array_value item 4 to 1
> end_object
>
> for iItem from 0 to 4
> show (value (oTest (current_Object), iItem)) ', '
> loop
> showln
>
> send sort_items to (otest (current_object))
>
> for iItem from 0 to 4
> show (value (oTest (current_Object), iItem)) ', '
> loop
> showln
>
> object otest2 is an array
> set value item 0 to 3
> set value item 1 to 13
> set value item 2 to 11
> set value item 3 to 10
> set value item 4 to 1
> end_object
>
> for iItem from 0 to 4
> show (value (oTest2 (current_Object), iItem)) ', '
> loop
> showln
>
> send sort_items to (otest2 (current_object))
>
> for iItem from 0 to 4
> show (value (oTest2 (current_Object), iItem)) ', '
> loop
> showln
>
>
> inkey sKey
>
Vincent Oorsprong
14-Feb-2006, 01:53 AM
Chris,
What documentation are you referring to? The uimsref.pdf (for CM
DataFlex) has the method documented.
--
Regards,
Vincent Oorsprong
Data Access Europe B.V.
http://www.dataaccess.nl
Chris Spencer
14-Feb-2006, 02:47 AM
Doh
I am thinking I am in VDF NG.
But is the same for VDF? If so it ain't in the VDF 11 help
Chris Spencer
TUFware Systems
"Vincent Oorsprong" <vincent.oorsprong@reply.at.newsgroup.nl> wrote in
message news:5$I1YNTMGHA.2932@dacmail.dataaccess.com...
> Chris,
>
> What documentation are you referring to? The uimsref.pdf (for CM DataFlex)
> has the method documented.
>
> --
> Regards,
> Vincent Oorsprong
> Data Access Europe B.V.
> http://www.dataaccess.nl
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.