PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Sorting per date and Per name  (Read 307 times)

Petrus Vorster

  • Senior Member
  • ***
  • Posts: 487
Sorting per date and Per name
« on: April 08, 2021, 09:45:08 AM »

Good Day gents

How do one sort an Array or a listview like Excel?
First by DATE, then by Name of user or his Employee number?

I have a report that gives me the transactions PER DAY in DATE ORDER but since many employees log on into multiple systems, it will give it in sequence of those actions. For example:
2021-01-19 $500.00 George
2021-01-19 $600.00 Mark
2021-01-19 $800.00 George
2021-01-20 $300.00 Jane
and so forth.

Now i need to get all of GEORGE together under one date, then MARK, and so forth.
The dates in Sequence and the names together.

In Excel it called Layer one and Layer two sorting, but the users isn't very clued up.
It also consumes too much time before an audit sorting all their sheets before heading out to branches.

It would be great if i could just export my file to Excel already sorted, or give a command to Excel to sort like that.

This is still in PB though.

-Regards, Peter

Paul Squires

  • Administrator
  • Guru Member
  • *****
  • Posts: 9411
  • Windows 10
    • PlanetSquires Software
Re: Sorting per date and Per name
« Reply #1 on: April 08, 2021, 08:17:54 PM »

Hi Peter,

You say that your data is in an array, right. Is that an array of TYPE records?

I know that PB has built in sort functions for arrays but it has been years since I touched them... and I think that even back then I had been using my own Quicksort algorithm routines instead.

I suggest trying this:

Create a new string array that holds the DATE and NAME all in one string. 
2021-01-19 George
2021-01-19 Mark

Use PB's TAGARRAY functionality to link each element in your newly constructed array above back to the original TYPE array.

Do the PB SORT on the newly constructed string array.

Now you should be able to read through the newly sorted array and link back to the original data that is still in unsorted format.

.....all of this is just off the top of my head so not sure if it will work. Like I said, it's been a very long time since I touched anything PB related.

Paul Squires
PlanetSquires Software
WinFBE Editor and Visual Designer

Petrus Vorster

  • Senior Member
  • ***
  • Posts: 487
Re: Sorting per date and Per name
« Reply #2 on: April 09, 2021, 12:27:39 PM »

Hi Paul

I will give this a try, thank you.
At the moment, as i read through the Original TXT from their system, I drop it into a Listview control.
I once made a little routine that exports any Listview using your Sll and then open Excel.

But it should be fairly easy to create an Array.
I will work on this over the weekend, hope to get it right.

Audit teams desperate with all  these criminals running rife in government sectors.

Regards, Peter