lbSortBy: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - " \|([ps][0-9]+) *= " to " |$1= ")
m (Fix)
 
(10 intermediate revisions by the same user not shown)
Line 5: Line 5:


|gr1= GUI Control - ListBox
|gr1= GUI Control - ListBox
|branch= dev


|descr= Sorts given ListBox by either [[lbText]], [[lbValue]] or [[lbData]] in normal or reversed order, using case-sensitive or case-insensitive comparison. This command supports UNICODE characters.
|descr= Sorts given ListBox by either [[lbText]], [[lbValue]] or [[lbData]] in normal or reversed order, using case-sensitive or case-insensitive comparison. This command supports UNICODE characters.
When sorting by <tt>"VALUE"</tt>, the rows with the same [[lbValue]] will additionally be sorted by [[lbText]] in the order specified by `reversedOrder` flag, text specified by `useTextRight` flag and case-sensitivity specified by `caseSensitive` flag.
When sorting by {{hl|"VALUE"}}, the rows with the same [[lbValue]] will additionally be sorted by [[lbText]] in the order specified by `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| As this command supports UNICODE by default, which may result in slower sorting, you can switch it off with <tt>unicodeOff</tt> param.}}


{{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]].
* As this command supports UNICODE by default, which may result in slower sorting, you can switch it off with {{hl|unicodeOff}} param.
}}


|s1= controlOrIDC [[lbSortBy]] [sortByType, reversedOrder, caseSensitive, useTextRight, unicodeOff]
|s1= controlOrIDC [[lbSortBy]] [sortByType, reversedOrder, caseSensitive, useTextRight, unicodeOff]
Line 19: Line 18:
|p1= controlOrIDC: [[Control]] or [[Number]] - the ListBox control or its IDC
|p1= controlOrIDC: [[Control]] or [[Number]] - the ListBox control or its IDC


|p2= [sortByType, reversedOrder, caseSensitive, useTextRight, unicodeOff]: [[Array]]
|p2= sortByType: [[String]] - (Optional, default "TEXT") one of:
 
* {{hl|"TEXT"}}
|p3= sortByType: [[String]] - (Optional, default "TEXT") one of:
* {{hl|"VALUE"}}
* <tt>"TEXT"</tt>
* {{hl|"DATA"}}
* <tt>"VALUE"</tt>
* <tt>"DATA"</tt>


|p4= reversedOrder: [[Boolean]] - (Optional, default [[false]]) [[true]] for sorting in reversed order
|p3= reversedOrder: [[Boolean]] - (Optional, default [[false]]) [[true]] for sorting in reversed order


|p5= caseSensitive: [[Boolean]] - (Optional, default [[false]]) [[true]] for using case-sensitive comparison
|p4= caseSensitive: [[Boolean]] - (Optional, default [[false]]) [[true]] for using case-sensitive comparison


|p6= useTextRight: [[Boolean]] - (Optional, default [[false]]) [[true]] to sort by [[lbSetTextRight | text right]]
|p5= useTextRight: [[Boolean]] - (Optional, default [[false]]) [[true]] to sort by [[lbSetTextRight | text right]]


|p7= unicodeOff: [[Boolean]] - (Optional, default [[false]]) [[true]] to switch off UNICODE conversion for faster sorting
|p6= unicodeOff: [[Boolean]] - (Optional, default [[false]]) [[true]] to switch off UNICODE conversion for faster sorting


|r1= [[Nothing]]
|r1= [[Nothing]]


|x1= <code>[[with]] [[uiNamespace]] [[do]]
|x1= <sqf>
with uiNamespace do
{
{
[[private]] _lb = [[findDisplay]] 46 [[createDisplay]] "RscDisplayEmpty" [[ctrlCreate]] ["RscListBox", -1];
private _lb = findDisplay 46 createDisplay "RscDisplayEmpty" ctrlCreate ["RscListBox", -1];
_lb [[ctrlSetPosition]] [0,0,1,1];
_lb ctrlSetPosition [0,0,1,1];
_lb [[ctrlCommit]] 0;
_lb ctrlCommit 0;
[[lbClear]] _lb;
lbClear _lb;
{
{
_lb [[lbAdd]] (_x [[select]] 0);
_lb lbAdd (_x select 0);
_lb [[lbSetValue]] [<nowiki/>[[_forEachIndex]], _x [[select]] 1];
_lb lbSetValue [_forEachIndex, _x select 1];
}
}
[[forEach]] [["В",1], ["Я",0], ["Б",1], ["Ю",0], ["А",1]];
forEach [["В",1], ["Я",0], ["Б",1], ["Ю",0], ["А",1]];
_lb [[lbSortBy]] ["VALUE", [[false]], [[false]]];
_lb lbSortBy ["VALUE", false, false];
};</code>
};
</sqf>


|seealso= [[lnbSortBy]], [[lnbSort]], [[lnbSortByValue]], [[lbSort]], [[lbSortByValue]], [[tvSort]], [[tvSortByValue]], [[sort]]
|seealso= [[lnbSortBy]] [[lnbSort]] [[lnbSortByValue]] [[lbSort]] [[lbSortByValue]] [[tvSort]] [[tvSortByValue]] [[sort]]
}}
}}

Latest revision as of 19:24, 5 May 2022

Hover & click on the images for description

Description

Description:
Sorts given ListBox by either lbText, lbValue or lbData in normal or reversed order, using case-sensitive or case-insensitive comparison. This command supports UNICODE characters. When sorting by "VALUE", the rows with the same lbValue will additionally be sorted by lbText in the order specified by `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 - ListBox

Syntax

Syntax:
controlOrIDC lbSortBy [sortByType, reversedOrder, caseSensitive, useTextRight, unicodeOff]
Parameters:
controlOrIDC: Control or Number - the ListBox control or its IDC
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 _lb = findDisplay 46 createDisplay "RscDisplayEmpty" ctrlCreate ["RscListBox", -1]; _lb ctrlSetPosition [0,0,1,1]; _lb ctrlCommit 0; lbClear _lb; { _lb lbAdd (_x select 0); _lb lbSetValue [_forEachIndex, _x select 1]; } forEach [["В",1], ["Я",0], ["Б",1], ["Ю",0], ["А",1]]; _lb lbSortBy ["VALUE", false, false]; };

Additional Information

See also:
lnbSortBy lnbSort lnbSortByValue lbSort lbSortByValue tvSort tvSortByValue sort

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