I have a large field with many columns.
The first column is Patient Number
2nd column is Patient Ledger Number
3rd Column is Date of Service
I need to sort by patient number, then by the date of service.
When I do a regular sort, it does not sort the dates correctly.
Any suggestions?
Sort by first column, then by date in 3rd column
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: Sort by first column, then by date in 3rd column
I am guessing (without seeing your code) that when you say 'regular sort', you mean that your not specifying what your sorting, but more using sort as a shotgun. By default, I believe sort treats everything as text.
If you need to sort numbers, then you would write it something like
Pretty sure 'sort' in the dictionary goes into it pretty well. You can also use different metrics to sort, for instance
You can make it as involved or simple as you need it.
*Edit - I checked, and this is what the dictionary says about sort type.
If you need to sort numbers, then you would write it something like
Code: Select all
sort field "xyz" numeric ascending
// if you want it highest to lowest, it would be 'descending'...
Code: Select all
sort the lines of field 1 by word 3 of each
*Edit - I checked, and this is what the dictionary says about sort type.
sortType enum
If you don't specify a sortType, the sortType is text.
Sort types -
- international -sorts by collation according to the system locale
- numeric -sorts by number. (Use this form if the sortKey consists of
- datetime -treats the sortKey as a date and/or time
- text -sorts using a codepoint by codepoint comparison
- binary -sorts using a byte by byte comparison
-
- VIP Livecode Opensource Backer
- Posts: 9647
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Sort by first column, then by date in 3rd column
Hi.
Know also that you can combine a sort using "&":
And as Bogs mentioned, be sure that you include the correct sortKey, like "numeric" or "Datetime", or LC will not do what you want it to. Practice a bit on a field with a list of random text..
And know also that you cannot mix sortKey "styles" in the compact form above. In that case, where you want to sort by more than one style, you need to sort on separate lines. The good news is that LC provides stable sorts, so that each time you do sort, the previous order is maintained to the extent it can be, based on the latest sort.
That's a lot of sort
Craig Newman
Know also that you can combine a sort using "&":
Code: Select all
on mouseUp
sort fld 1 by word 2 of each & word 1 of each
end mouseUp
And know also that you cannot mix sortKey "styles" in the compact form above. In that case, where you want to sort by more than one style, you need to sort on separate lines. The good news is that LC provides stable sorts, so that each time you do sort, the previous order is maintained to the extent it can be, based on the latest sort.
That's a lot of sort
Craig Newman