Sorting the columns of a JavaFX TableView - tableview

Now I have been searching for quite a while and all I find are people trying to sort the TableRows through a TableColumn, but I want to sort the TableColumns alphabetically.
Say I have a Table with the columns 'Name', 'Pain' and 'Gain' and after sorting I would like it to be 'Gain', 'Name' and 'Pain'.
Can't really figure out a way to do this, but it can't be that hard, can it ?
... I wanna do it programmatically of course and not drag the columns around.

Sorry I don't have time to post code right now, but here is a method that should work:
Create a Comparator<TableColumn> that will sort by column name.
Apply the sort by myTableView.getColumns().sort(myComparator)
Where myTableView is the name of your TableView and myComparator is the name of the Comparator<TableColumn> you created.

Related

Google Sheets - QUERY order by dependent drop down

I am trying to setup a QUERY with dynamic ordering. I've tried to link the ORDER BY function to the output of the dropdown menu but that doesnt seem to work. I have recreated the problem with a simple example: https://docs.google.com/spreadsheets/d/1m3Lhm5lp2DW7XF8hRbDAiOAAsOyCXrie-Nc-0bWG6hA/edit?usp=sharing
I've created a table (3x4) with three variable and would like to dynamically sort the table by each variable through QUERY both ascending and descending.
Would also be interested to learn if it's possible to dynamically setup the direction (ACS or DESC).
Any suggestions would be much appreciated.
Kind regards,
Webko
try:
=QUERY({A2:C6}, "order by Col"&MATCH(F1, A2:C2, 0)&" "&G1)
where G1 dropdown is asc,desc

Google script - Sheets - sort - how to avoid sorting the first row?

A stupid thing that got me cracking my head. I'm sure you'll laugh, but how do I
sort a sheet without including the first row in the sort?
Here's my code:
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("test1");
spreadsheet.sort(4); // or spreadsheet.sort(4,false); or spreadsheet.sort(4,true);
This sorts by column D, but it also sorts the first row. Column D contains only text.
Funny thing is that if you sort a column which has just numbers/dates, it works and it indeed avoids sorting the first row.
So, how can I sort a column with text and avoid sorting the first row?
I know that I can set a range start at A2 until the last column but this seems "messy". Something like this
spreadsheet.getRange('A2:AI').sort({column: 4, ascending: true});
Thanks
What about this solution:
Freeze the header row and then perform the sorting operation.
In this way it's easy and readable to select the row that will contain the headers of your spreadsheet and you can apply all the sorting operations with a cleaner syntax:
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("test1");
spreadsheet.setFrozenRows(1);
spreadsheet.sort(4);
Reference
.setFrozenRows()
You'll probably find this "messy" too but maybe you could save the first item, sort your column and insert back the first item ?
About the working sort of dates/numbers, maybe the sheet detects that the first cell is the only different one (not a number or a date) and then don't sort it ?

Can a PowerApps gallery be sorted from a derived column?

I have a PowerApps gallery that lists data from 3 different tables and have it normally sorted by the following:
SortByColumns(Filter(Personnel, !Dismissed, txtMSSearchBox.Text in MemberName), "MemberName", If(SortDescending1, SortOrder.Descending, SortOrder.Ascending))
One of the fields is displayed from the below:
Last(SortByColumns(Filter(PersonnelEvents, MemberNumber.Id = ThisItem.ID, EventType.Value="Promotion"), "Date", SortOrder.Ascending)).Title
What I would like to do is sort the gallery by this derived data. Is this even possible?
Can you try making On visible of the screen have an UpdateContext function which saves this formula as a variable.
You can then reference this variable as the column you want to sort by.
i.e something like UpdateContext({mySortColumn: Last(SortByColumns(Filter(PersonnelEvents, MemberNumber.Id = ThisItem.ID, EventType.Value="Promotion"), "Date", SortOrder.Ascending)).Title})
I just hope I really understand what you are trying to achieve, but if this doesn't work, maybe you can explain better what you are trying to do and hopefully I'll be able to help
I have decided to use Flow to update a column in my main table to show the relevant data and thereby sort by that field. I believe this would be an easier way to accomplish what I want.

Gnumeric Sort function

Can someone please direct me to a detailed explanation (link) of the Gnumeric sort function? The Gnumeric manual is abbreviated and has no examples. I haven't been able to find any appropriate info through the search engines and even Stackoverflow only has half a dozen questions on it which don't suit.
My problem is:
I have a table with rows of dates, names, and columns of data. (pretty straightforward stuff).
I want to sort ALL columns by the NAME column.
That is: keep each row intact for data but move them in the table up or down so that the order is alphabetic by name.
I can do this easily with Libercalc but prefer the feel and simplicity of Gnumeric, yet I have never been able to understand from the drop-down sort menu how to get this done. I can sort any column fine by itself, but can't seem to lock the other data in the row to be taken with it.
This is such a frequent function I'm surprised it's not made clearer in the drop-down menu. That is: Order by column x
The only way one can sort with Gnumeric, apparently, is to move the key column (i.e. in my case the NAME column) to be the left-most column (column A) in the table, and then sort, subsequently moving the columns back into their required format (date and time in first column) as I want it. This seems very clumsy to me and I wondered if there was an easier way of ordering a table in any format (e.g. just as it is imported from the csv file) by simply selecting the column to sort wherever it is in the table, as can be done in LiberCalc?
1) You need to select ALL the columns you want to sort:
menu > data > sort
2) Keep the column with the NAMEs to be sorted, and remove the rest of the columns in:
sort specification

Qlikview chart sorting doesn't always work for users

I have several Qlikview charts that have interactive sorting enabled but the odd part is some columns can be sorted ascending or descending and others can only be sorted one way. Nothing happens if you click on the column again.
Each field has a proper sort defined, it looks like a bug - anyone else experience this?
Thanks
Dan
It happens often when on the sort tab of the properties it has selected more than one way of sorting for example you have a field that has sort as text and numeric value

Resources