Custom Array Sorting

More advanced topics discussed.

Moderators: Susan Smith, admin, Gabriel

Post Reply
John
Posts: 555
Joined: Sun Apr 26, 2009 8:27 am

Custom Array Sorting

Post by John »

I need to sort an array by a customized order (with symbols and underscores after letters instead of before) What is the easiest way to do that?

-John
gtisdale
Posts: 218
Joined: Sun Jun 07, 2009 7:54 am
Location: Concord, Massachusetts
Contact:

Post by gtisdale »

FNSNAP fnsrtary or fnsortarray

60320 DEF LIBRARY FNSRTARY(MAT L$;MAT M$,DESENDING,HEADER,FOOTER) !: ! Sorts MAT L$ in ascending order !: ! OPtionally based on MAT M$ !: ! In Descending order if DESending !: ! starting down from top to allow for a HEADER !: ! stopping before the bottom to allow for a FOOTER

or

04550 DEF LIBRARY FNSORTARRAY(MAT L$,START,LENGTH;DESENDING,HEADER,FOOTER) !: ! ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿!: ! ³ Sorts an array based on a substring within the array and ³!: ! ³ optionally omits lines at the top and bottom from the sort ³!: ! ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ!
John
Posts: 555
Joined: Sun Apr 26, 2009 8:27 am

Post by John »

Will these functions allow me sort in a custom order? I don't see any parameters for that.

I checked out the documentation for them on the BR Wiki.

http://brwiki.brulescorp.com/index.php? ... _Functions

They don't look like they will fit the bill, but maybe I'm missing something.

-John
gtisdale
Posts: 218
Joined: Sun Jun 07, 2009 7:54 am
Location: Concord, Massachusetts
Contact:

Post by gtisdale »

By "Custom order" do you mean other than ASCII hiarchy? or do you mean a subset of positions within each string?

For example do you want all item that contain an "X" regardless of where it exxists in the string to sort before "A" and after "?".

If so you would need to build a separte array that contained some key to those and reference it in FNSRTARY as array M on which array L would be sorted.
John
Posts: 555
Joined: Sun Apr 26, 2009 8:27 am

Post by John »

Yes, I need to change it from regular ASCII order to one where symbols and underscores are after the letters instead of before.
John
Posts: 555
Joined: Sun Apr 26, 2009 8:27 am

Post by John »

I can write a routine to do it - I was just hoping there was some internal function I didn't know about... I hate to do work that doesn't need to be done, ya know. :)
gtisdale
Posts: 218
Joined: Sun Jun 07, 2009 7:54 am
Location: Concord, Massachusetts
Contact:

Post by gtisdale »

I have not tried it, but have you attempted to create a COLLATE ALTERNATE file and used the CONFIG ALTERNATE ability?
John
Posts: 555
Joined: Sun Apr 26, 2009 8:27 am

Post by John »

Ooooooh - Good idea! I'll check that out! Thank you!
Post Reply