Android Question Sorting 3 arrays using QuickSort


Licensed User
Longtime User
Hi guys,

I was wondering if anyone could help me. This shouldn't be very difficult to achieve, but since I'm back to work this week, I don't have much time to code...

Anyway, here it goes:
I have 3 arrays of size n. For simplification purposes, n = 6.
Dim a(6) as Float
Dim b(6) as Float
Dim c(6) as Float


Let's use these values as example.

Now, what I need is a B4A algorithm which sorts (descending) array C using Quicksort.
I want these arrays to be "linked horizontally", so that both A and B arrays are also sorted according to the values of C.

This isn't related to databases at all, so using MySQL commands won't work.
Also, I specifically need this to be done with arrays, I don't want to use lists.


Well-Known Member
Licensed User
Longtime User
My first suggestion would be to use one array, and fill it with a type that contains the values.

Type Row(A as float, B as float, C as float)
Dim Rows(6) as Row

Then you can write a quicksort to sort that array based on Rows(x).C.

The other, less elegant way, is simply to sort the C array, and whenever you move something in that array, you also move it in the other two arrays.
Upvote 0


Licensed User
Longtime User
this one is rather simple but on more complex things you could insert it to some temp SQLite table and pull it back in with the different sorting methods (or other actions) you require.
Upvote 0