7 Replies Latest reply on Jan 4, 2017 12:20 PM by jbante

# De mortuis nil nisi bonum

sorry - my non-question has been erased.

• ###### 1. Re: Bubble Sort Custom Function

What I remember about the bubble sort algorithm from my ancient college days is that:

a) it's very simple compared to most sort algorithms

b) it's very, very inefficient. The number of iterations needed to sort the values varies with the square of the number of value to sort as compared to more efficient sorts that vary proportionally to the number of items times the log of the number of items to sort.

For a relatively small number of items in an array, that may not be an issue, but be careful if you try to "scale up" to a much larger array of values.

• ###### 2. Re: Bubble Sort Custom Function

Leaves the variable space filled up with the \$\$tempSortList[N] variables.

Appears to fail for N > 157.

You might also look at this from the Brian Dunning site: FileMaker Custom Function:BubbleSort ( inputValues ; iterations )

• ###### 3. Re: Bubble Sort Custom Function

Ditto. Not as efficient. Small number of items only.

Push items to a virtual list and use native FM sort or something. Thanks for the efforts, tho David!

Sent from miPhone

• ###### 4. Re: Bubble Sort Custom Function

I stated clearly up front that this was an exercise.  What I didn't state was that this was also bait to draw out the "projectionists".  I was fully expecting an onslaught of condescension and one-upmanship, often made the guise of "advice".

In a short while, I'll do what I can to erase my post.  If I can't - sorry.  Don't expect me to feed your responses.  Happy New Year.  Health and happiness to you.

• ###### 5. Re: Bubble Sort Custom Function

To elaborate on the computer science, the number of comparisons for Bubblesort is O(n^2) ("Big-O", meaning roughly "on the order of"), or "quadratic" for the easy thing to say out loud. Insertionsort is another quadratic algorithm with better properties.

The best theoretically possible worst-case performance for any pair-wise comparison-based sort algorithm is O(n*log(n)), or "linearithmic". Mergesort is a simple algorithm that achieves this. Timsort is a more complicated algorithm with much better O(n) (linear) best-case performance.

Any sorting algorithm in FileMaker using return-delimited lists for input will have a performance constraint due to the time it takes to extract individual values from the list. The basic GetValue ( list ; \$i ) approach is quadratic, even without a sort algorithm on top. Practically, O(n^1.5) performance for parsing a list in FileMaker is possible. With a linearithmic sort algorithm, this work just to parse the list will dominate the work done by the sort algorithm in a large list. Performance can still be incrementally improved by a better algorithm, just not in the sense captured by Big-O notation.

• ###### 6. Re: Bubble Sort Custom Function

Meanwhile, here's a mod to the file which includes the Greg Lane method and which triggers an auto-enter sort result by using a global radio button.

Apparently - grab it while you can. If interested.

• ###### 7. Re: Bubble Sort Custom Function

David Moyer wrote:

I stated clearly up front that this was an exercise. What I didn't state was that this was also bait to draw out the "projectionists". I was fully expecting an onslaught of condescension and one-upmanship, often made the guise of "advice".

Is that not another form of condescension? A forum post is an invitation to conversation. People come to the forum to improve their own practices and to help others improve. Some folks may engage in what appears to be "one-upmanship", but it is rarely possible to distinguish between that and honest input, and even less often useful to try. We want everyone in the FileMaker community creating the best solutions they can, but folks frequently adopt the first practice on the forums they find that works (regardless of the purpose of the original post), so it's only natural that we might want folks to also see alternatives with possible advantages in the same thread. There are worse ways to boost an ego.

Please post in good faith. Please don't feed the trolls, lest you become one.

2 of 2 people found this helpful