Re Organize array by content value

Yuval S.
Tel Aviv,

Dec 27, 2018
10 Posts

0  |  0  

Re: Re Organize array by content value

Hi,

need help...

I have an array of 10 numbers
Arr = {2,9,5,7,8,4,1,0,6,3}

i want to re organize the array by content value:
Arr = {0,1,2,3,4,5,6,7,8,9,}

Is there a command that will make this process short instead of using a for loops ?

Thanks !

Solution Available
Yuval S.
Tel Aviv,

Dec 27, 2018
10 Posts

1  |  0  

Re: Re Organize array by content value

Arr = {2,9,5,7,8,4,1,0,6,3}

    Print "This the Array:\r\n"
        
    for i = 0 to (VarDimSize(Arr)-1)
    print (str(Arr[i]))
    next

    for j = 1 to (VarDimSize(Arr)-1)
        for i=0 to (VarDimSize(Arr)-2)
            if Arr[i] > Arr[i+1] then
                Temp = Arr[i]
                Arr[i] = Arr[i+1]
                Arr[i+1] = Temp

            EndIf


        Next

    Next

    Print "This is the Array after sort:\r\n"

    for i = 0 to (VarDimSize(Arr)-1)
    print (str(Arr[i]))
    next


I succeded to do this with two for loops.



Please Note
You need to have a M@GIC account to participate in the Forums.
Not yet registered on our website? Click here to register today!

All content, information and opinions presented on the Marvin Test Solutions User Forums are those of the authors of the posts and messages and not Marvin Test Solutions'. All attachments and files are downloaded at your own risk. [Read More]