Sorting an array
Jose Lerebours
fpgroups at gmail.com
Wed May 18 15:50:55 PDT 2016
Like I said, there is always a way to skin the cat!
Bubble sort has been around for as long as what we know as "computer"
language has ...
Go ahead, use Basic for this task and hope you can use it for your next
task, and the next one, and the next one ...
Perhaps, you are better off installing/creating patches as you encounter
needs/difficulties and then have someone like Mark or I tell you all you
did wrong and how we would have done it differently ... lol Point is,
each one of us will likely lean in a "bias" direction due to personal
preference, professional experience or simply to be a jerk and disagree
with what others have suggested.
As I said, "I prefer PHP", did not suggest it was the "best nor only"
solution. Over Basic, I still choose PHP. If I am not mistaken, you
may be able to install it, run it as "scripts" and not have to install
Apache nor MySQL if resource is an issue. Sorting array in PHP is as
simple as:
<?php
$cars = array("Volvo", "BMW", "Toyota");
rsort($cars);
?>
http://www.w3schools.com/php/php_arrays_sort.asp
Do not be ashamed if you have to resort to dumping data to a filePro
file and read it back, you do what you must to get the job done. This is
quick and easy within your environment. It is a common practice to
create temporary tables to store, manipulate data and doing so in
filePro should not be cause of shame. In SQL, one normally creates
tables, dump data in these tables, do what needs to be done with them
and later drop the table; while you cannot do the exact same things in
filePro, you can at least employ this commonly and very "basic"
approach. In fact, a developer that had never resorted to this kind of
practice has have limited exposure to developing data management
applications.
Then again, some one like J.P. or Barry (??) White may point you to a
windows version of "awk" that will get the job done just the same.
On 05/18/2016 06:01 PM, Fairlight via Filepro-list wrote:
> On Wed, May 18, 2016 at 04:45:01PM -0400, Jose Lerebours via Filepro-list thus spoke:
>> I am not even sure that filePro has methods built in to do so.
> It does not.
>
>> That being said, there is always a way to skin the cat. A quick and
>> dirty way to do this to simply dump the data into a filePro file and
>> read back from that file as needed. By doing so, you have as many
>> ways to sort your array as there are indexes (provided that you have
>> a multi-level array).
> Dear Lord.
>
>> If you were to install WAMP in your box, you can write PHP scripts
>> which you can then call to manipulate the data and send it back in
>> the order you expect by using filePro's own "user" command. I am
>> sure you could do same with Perl, Python and a ton of other
>> languages by PHP is the one I prefer.
> Oh, bloody hell, seriously? Dear Lord.
>
> While I'm the first to advocate taking certain things outside of filePro
> because the language is simply not capable of doing them, there is -no-
> need to invoke an entire additional architecture to accomplish something
> you can do in -BASIC-. And I'm talking regular line-number-based AppleSoft
> BASIC, not that VB crud MS came up with later.
>
> https://en.wikipedia.org/wiki/Bubble_sort
>
> Bubble sorts are not the most elegant or best performers, but for a
> 20-element use case they're going to be just fine.
>
> mark->
More information about the Filepro-list
mailing list