03-18-2025 11:37 AM - edited 03-18-2025 12:01 PM
Hello guys,
I have this cluster array, I would like to redefine it with the following rules:
Sort by longest duedate date (from closest to farthest)
After appearing the items that duedate are empty
If possible:
Reorder the empties duedate from oldest to newest by sorting by created
Could you help me?
03-18-2025 12:38 PM
Sorts by duedate, You can do the same kind of sort for the date created.
03-18-2025 01:13 PM
That's a great solution.
The first loop could also detect the empty due dates and then create a second array of data from the date created to be then sorted out on another stage.
03-18-2025 01:13 PM - edited 03-18-2025 01:15 PM
Jay's solution obviously works but for a touch more explanation, the "Sort" function can sort clusters directly. It just sorts it by the first element. You would need to reorder the controls in your cluster.
Also, depending on your use case, you can look at a couple options. The first is to use a database to handle this, which you could query with simple commands. I'd recommend SQLite which is a single file you can interact with.
Also, if you replace the cluster with objects, you can specify your own "Greater than" operator for the class and use "Sort 1D array.vim":
You'd need to replace your string date/time controls with timestamps for the best "sortability" IMHO. Just depends on what exactly you're trying to accomplish long term.
03-18-2025 01:29 PM - edited 03-18-2025 01:30 PM
When I get to the items where the due date is empty, it's copying the last row that had due date and copying it to the rest of the rows
03-18-2025 01:56 PM
03-18-2025 02:30 PM
@leandrofeder wrote:
When I get to the items where the due date is empty, it's copying the last row that had due date and copying it to the rest of the rows
The find in array finds the first instance, you need to do a nested sort on all the blank duedates and sort them by date created. Also in your example the timestamps are unique which makes the find in array work. If the timestamps are not unique, you get the issue you noted and will have to figure out soemthing clever to handle that case : )
03-18-2025 08:15 PM
@BertMcMahan wrote:
Jay's solution obviously works but for a touch more explanation, the "Sort" function can sort clusters directly. It just sorts it by the first element. You would need to reorder the controls in your cluster.
Also, depending on your use case, you can look at a couple options. The first is to use a database to handle this, which you could query with simple commands. I'd recommend SQLite which is a single file you can interact with.
Also, if you replace the cluster with objects, you can specify your own "Greater than" operator for the class and use "Sort 1D array.vim":
You'd need to replace your string date/time controls with timestamps for the best "sortability" IMHO. Just depends on what exactly you're trying to accomplish long term.
You can define a custom comparison without using objects. The VIM takes static VI reference too.
03-19-2025 10:19 AM
@avogadro5 wrote:
You can define a custom comparison without using objects. The VIM takes static VI reference too.
Did not know that, thanks!