lnbSortBy: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(note about performance)
m (dev → main)
(4 intermediate revisions by 2 users not shown)
Line 6: Line 6:
|gr1= GUI Control - ListNBox
|gr1= GUI Control - ListNBox


|branch= dev
|descr= Sorts given multi-column ListNBox in the given column by either [[lnbText]], [[lnbValue]] or [[lnbData]] in normal or reversed order, using case-sensitive or case-insensitive comparison. Unlike the older '''lnbSortXXX''' commands, this command supports UNICODE characters out of the box.<br>
 
|descr= Sorts given multi-column ListNBox in the given column by either [[lnbText]], [[lnbValue]] or [[lnbData]] in normal or reversed order, using case-sensitive or case-insensitive comparison. Unlike the older '''lnbSortXXX''' commands, this command supports Unicode characters out of the box.<br>
When sorting by <tt>"VALUE"</tt>, the rows with the same [[lnbValue]] will additionally be sorted by [[lnbText]] in the order specified by the ''reversedOrder'' flag, text specified by `useTextRight` flag and case-sensitivity specified by `caseSensitive` flag.
When sorting by <tt>"VALUE"</tt>, the rows with the same [[lnbValue]] will additionally be sorted by [[lnbText]] in the order specified by the ''reversedOrder'' flag, text specified by `useTextRight` flag and case-sensitivity specified by `caseSensitive` flag.


{{Feature|Important|This command supports referencing control via IDC as well, but as with any use of IDC in UI [[Control]] commands, a [[dialog]] should be present, i.e. UI user interaction is created with [[createDialog]] rather than [[createDisplay]]}}
{{Feature|Important|
{{Feature|Warning|Be aware that this command is a lot slower than [[lnbSort]]!}}
* This command supports referencing control via IDC as well, but as with any use of IDC in UI [[Control]] commands, a [[dialog]] should be present, i.e. UI user interaction is created with [[createDialog]] rather than [[createDisplay]].
* As this command supports UNICODE by default, which may result in slower sorting, you can switch it off with <tt>unicodeOff</tt> param.
}}


|s1= [controlOrIDC, column] [[lnbSortBy]] [sortByType, reversedOrder, caseSensitive, useTextRight]
|s1= [controlOrIDC, column] [[lnbSortBy]] [sortByType, reversedOrder, caseSensitive, useTextRight,  unicodeOff]


|p1= [controlOrIDC, column]: [[Array]]
|p1= [controlOrIDC, column]: [[Array]]
Line 22: Line 22:
|p3= column: [[Number]] - column to sort (starts with 0)
|p3= column: [[Number]] - column to sort (starts with 0)


|p4= [sortByType, reversedOrder, caseSensitive, useTextRight]: [[Array]]
|p4= [sortByType, reversedOrder, caseSensitive, useTextRight, unicodeOff]: [[Array]]


|p5= sortByType: [[String]] - (Optional, default "TEXT") one of:
|p5= sortByType: [[String]] - (Optional, default "TEXT") one of:
Line 34: Line 34:


|p8= useTextRight: [[Boolean]] - (Optional, default [[false]]) [[true]] to sort by [[lnbSetTextRight | text right]]
|p8= useTextRight: [[Boolean]] - (Optional, default [[false]]) [[true]] to sort by [[lnbSetTextRight | text right]]
|p9= unicodeOff: [[Boolean]] - (Optional, default [[false]]) [[true]] to switch off UNICODE conversion for faster sorting


|r1= [[Nothing]]
|r1= [[Nothing]]
Line 40: Line 42:
{
{
[[private]] _column = 1;
[[private]] _column = 1;
[[private]] _lnb = [[findDisplay]] 46 [[createDisplay]] "RscDisplayEmpty" [[ctrlCreate]] ["RscListNBox", -1];  
[[private]] _lnb = [[findDisplay]] 46 [[createDisplay]] "RscDisplayEmpty" [[ctrlCreate]] ["RscListNBox", -1];
_lnb [[ctrlSetPosition]] [0,0,1,1];  
_lnb [[ctrlSetPosition]] [0,0,1,1];
_lnb [[ctrlCommit]] 0;  
_lnb [[ctrlCommit]] 0;
[[lnbClear]] _lnb;
[[lnbClear]] _lnb;
{  
{  
_lnb [[lnbAddRow]] [<nowiki/>[[format]] ["Row %1", [[_forEachIndex]]], _x select 0];  
_lnb [[lnbAddRow]] [<nowiki/>[[format]] ["Row %1", [[_forEachIndex]]], _x select 0];
_lnb [[lnbSetValue]] <nowiki>[[</nowiki>[[_forEachIndex]], _column], _x [[select]] 1];
_lnb [[lnbSetValue]] <nowiki>[[</nowiki>[[_forEachIndex]], _column], _x [[select]] 1];
}  
}  
[[forEach]] [["В",1], ["Я",0], ["Б",1], ["Ю",0], ["А",1]];  
[[forEach]] [["В",1], ["Я",0], ["Б",1], ["Ю",0], ["А",1]];
[_lnb, _column] [[lnbSortBy]] ["VALUE", [[true]], [[false]]];
[_lnb, _column] [[lnbSortBy]] ["VALUE", [[true]], [[false]]];
};</code>
};</code>

Revision as of 19:33, 5 October 2021

Hover & click on the images for description

Description

Description:
Sorts given multi-column ListNBox in the given column by either lnbText, lnbValue or lnbData in normal or reversed order, using case-sensitive or case-insensitive comparison. Unlike the older lnbSortXXX commands, this command supports UNICODE characters out of the box.
When sorting by "VALUE", the rows with the same lnbValue will additionally be sorted by lnbText in the order specified by the reversedOrder flag, text specified by `useTextRight` flag and case-sensitivity specified by `caseSensitive` flag.
  • This command supports referencing control via IDC as well, but as with any use of IDC in UI Control commands, a dialog should be present, i.e. UI user interaction is created with createDialog rather than createDisplay.
  • As this command supports UNICODE by default, which may result in slower sorting, you can switch it off with unicodeOff param.
Groups:
GUI Control - ListNBox

Syntax

Syntax:
[controlOrIDC, column] lnbSortBy [sortByType, reversedOrder, caseSensitive, useTextRight, unicodeOff]
Parameters:
[controlOrIDC, column]: Array
controlOrIDC: Control or Number - the ListNBox control or its IDC
column: Number - column to sort (starts with 0)
[sortByType, reversedOrder, caseSensitive, useTextRight, unicodeOff]: Array
sortByType: String - (Optional, default "TEXT") one of:
  • "TEXT"
  • "VALUE"
  • "DATA"
reversedOrder: Boolean - (Optional, default false) true for sorting in reversed order
caseSensitive: Boolean - (Optional, default false) true for using case-sensitive comparison
useTextRight: Boolean - (Optional, default false) true to sort by text right
unicodeOff: Boolean - (Optional, default false) true to switch off UNICODE conversion for faster sorting
Return Value:
Nothing

Examples

Example 1:
with uiNamespace do { private _column = 1; private _lnb = findDisplay 46 createDisplay "RscDisplayEmpty" ctrlCreate ["RscListNBox", -1]; _lnb ctrlSetPosition [0,0,1,1]; _lnb ctrlCommit 0; lnbClear _lnb; { _lnb lnbAddRow [format ["Row %1", _forEachIndex], _x select 0]; _lnb lnbSetValue [[_forEachIndex, _column], _x select 1]; } forEach [["В",1], ["Я",0], ["Б",1], ["Ю",0], ["А",1]]; [_lnb, _column] lnbSortBy ["VALUE", true, false]; };

Additional Information

See also:
lbSortBylnbSortlnbSortByValuelbSortlbSortByValuetvSorttvSortByValuesort

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note