sort an array

Bill Randall wrandall at fptech.com
Tue Jun 5 12:05:14 PDT 2018


I just changed the top 4 lines of the code to show alpha.
It has always worked well every time I have needed it.

@keyc::declare junk(6,*):
::dim dat(10)(6,*):
::dat("1")="Happy";dat("2")="Able";dat("3")="Doggy";dat("4")="Jump";dat("5")="Baby":
::dat("6")="Cat";dat("7")="Ezra";dat("8")="Poppy";dat("9")="Menu";dat("10")="System":


On 6/5/2018 12:59 PM, Richard D. Williams wrote:
> I've never tried this technique.  I assume it works with alpha-numeric data as well.
>
> I will experiment with this.
>
> Thanks,
>
> Richard
>
>
> On 6/5/2018 10:50 AM, Bill Randall wrote:
>> This is a sample of how I have always sorted arrays in filePro if needed.
>>
>> @keyc::declare junk(2,.0):
>> ::dim dat(10)(2,.0):
>> ::dat("1")="6";dat("2")="1";dat("3")="4";dat("4")="8";dat("5")="2":
>> ::dat("6")="3";dat("7")="5";dat("8")="10";dat("9")="7";dat("10")="9":
>> ::zx(2,.0)="1":
>> ::ct(2,.0)="1":
>> loop:::
>> :dat(zx) gt dat(zx+ct):gosub swap:
>> :junk ne "" and ct+zx lt "10":ct=ct+"1" ; goto loop:
>> :zx ne "9":zx=zx+"1" ; ct="1" ; goto loop:
>> ::x=listbox (dat,"1","10"):
>> ::end:
>> swap:::
>> ::junk=dat(zx+ct);dat(zx+ct)=dat(zx);dat(zx)=junk:
>> ::return:
>>
>>
>>
>> On 6/5/2018 11:26 AM, Richard D. Williams via Filepro-list wrote:
>>> Dave,
>>>
>>> I don't know of any function in FP that will sort an array.
>>>
>>> What I do is write the array data out to a temporary file that has an index built in the correct order,
>>> clear the array, reach back into the temporary file, and fill the array again.
>>>
>>> You can use the tty as a unique identifier for each instance.
>>>
>>> Hope this helps,
>>>
>>> Richard
>>>
>>>
>>> On 6/5/2018 9:28 AM, davidrottkamp via Filepro-list wrote:
>>>> Hi
>>>>
>>>> Is there a way to sort an array made inside filepro
>>>>
>>>> version
>>>>
>>>> linux
>>>>
>>>>
>>>
>>> _______________________________________________
>>> Filepro-list mailing list
>>> Filepro-list at lists.celestial.com
>>> Subscribe/Unsubscribe/Subscription Changes
>>> http://mailman.celestial.com/mailman/listinfo/filepro-list
>>>
>>
>>
>> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient&utm_term=icon> 	Virus-free. www.avast.com <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient&utm_term=link>
>>
>> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.celestial.com/pipermail/filepro-list/attachments/20180605/9b75dd03/attachment.html>


More information about the Filepro-list mailing list