blckeagls 12 Posted January 26, 2015 (edited) Hello All, I have an issue. I have 4 listboxes, and I want to be able to sort by any of them. But when you sort, the rows across all wont get sorted. I was wondering how do I go about getting the index order after the sort? (so i can sort the others by the index order) any help is greatly appreciated What I am looking for is this: _array = ["One","Two","Three"]; { lbAdd [1500,_x]; } foreach _array; _display = findDisplay 734234; _ctrl = _display displayctrl 1500; _order = lbSort _ctrl; // <--- this wont work, does not return value //_order will be [1,3,2]; <---- How do I get this??? I want to sort other listboxes in this order Edited January 26, 2015 by blckeagls Share this post Link to post Share on other sites
Larrow 2821 Posted January 26, 2015 LBSort does not return anything. It (as above) sorts Alphabetically ascending, you can also sort descending by using the alternative syntax lbSort [control, sortOrder] where sortOrder is "ASC" or "DESC". You will have to manually sort your other listboxes either by using the original order (_array) or you could store the original indexs in either LBValue or LBData if you are not using either of these. By original _array order _array = ["One","Two","Three"]; { lbAdd [1500,_x]; } forEach _array; _display = findDisplay 734234; _ctrl = _display displayCtrl 1500; lbSort _ctrl; { //Find ctrl myOtherLB = _display displayCtrl _x; //Array to save LB data in myOtherLBData = []; //Save data from each LB index for "_index" from 0 to ( lbSize myOtherLB ) do { myOtherLBData pushBack [ myOtherLB lbText _index, myOtherLB lbColor _index, myOtherLB lbPicture _index, myOtherLB lbValue _index, myOtherLB lbData _index ]; }; //Clear the LB lbClear myOtherLB; //Loop through each index of sorted LB for "_index" from 0 to ( lbSize 1500 ) do { //find original index of new item @ _index _oldIndex = _array find ( lbText [ 1500, _index ] ); //Get data from LB at original index _data = myOtherLBData select _oldIndex; //Add data _newIndex = myOtherLB lbAdd ( _data select 0 ); myOtherLB lbSetColor [ _newIndex, ( _data select 1 ) ]; myOtherLB lbSetPicture [ _newIndex, ( _data select 2 ) ]; myOtherLB lbSetValue [ _newIndex, ( _data select 3 ) ]; myOtherLB lbSetData [ _newIndex, ( _data select 4 ) ]; }; }forEach [ 1501, 1502, 1503 ]; //IDC's of other list boxes //Re-arrage _array if you need a reference to resort from _array = []; for "_index" from 0 to ( lbSize 1500 ) do { _array pushBack ( lbText [ 1500, _index ] ); }; Thinks thats right, untested, but should give you a base to work from. Share this post Link to post Share on other sites
blckeagls 12 Posted January 28, 2015 LBSort does not return anything. It (as above) sorts Alphabetically ascending, you can also sort descending by using the alternative syntax lbSort [control, sortOrder] where sortOrder is "ASC" or "DESC". You will have to manually sort your other listboxes either by using the original order (_array) or you could store the original indexs in either LBValue or LBData if you are not using either of these. By original _array order _array = ["One","Two","Three"]; { lbAdd [1500,_x]; } forEach _array; _display = findDisplay 734234; _ctrl = _display displayCtrl 1500; lbSort _ctrl; { //Find ctrl myOtherLB = _display displayCtrl _x; //Array to save LB data in myOtherLBData = []; //Save data from each LB index for "_index" from 0 to ( lbSize myOtherLB ) do { myOtherLBData pushBack [ myOtherLB lbText _index, myOtherLB lbColor _index, myOtherLB lbPicture _index, myOtherLB lbValue _index, myOtherLB lbData _index ]; }; //Clear the LB lbClear myOtherLB; //Loop through each index of sorted LB for "_index" from 0 to ( lbSize 1500 ) do { //find original index of new item @ _index _oldIndex = _array find ( lbText [ 1500, _index ] ); //Get data from LB at original index _data = myOtherLBData select _oldIndex; //Add data _newIndex = myOtherLB lbAdd ( _data select 0 ); myOtherLB lbSetColor [ _newIndex, ( _data select 1 ) ]; myOtherLB lbSetPicture [ _newIndex, ( _data select 2 ) ]; myOtherLB lbSetValue [ _newIndex, ( _data select 3 ) ]; myOtherLB lbSetData [ _newIndex, ( _data select 4 ) ]; }; }forEach [ 1501, 1502, 1503 ]; //IDC's of other list boxes //Re-arrage _array if you need a reference to resort from _array = []; for "_index" from 0 to ( lbSize 1500 ) do { _array pushBack ( lbText [ 1500, _index ] ); }; Thinks thats right, untested, but should give you a base to work from. Thanks for the help, unfortunately this does not help me. My issue is that I have an array of 5 values. Each element of the array goes into it's own list box. Some of the values being sorted have the same name but the other value are different. Also, after an lbSort, the index does not change, just the position in the list box. So if "Hello" was in Position 1 of the listbox before the lbSort is would have an index of 1. After the lbSort, lets say it is in postion 10, it would still have an index of 1. Share this post Link to post Share on other sites
Larrow 2821 Posted January 28, 2015 (edited) My issue is that I have an array of 5 values. Each element of the array goes into it's own list box. Thats not what your original post shows. It shows an array of three values all being added to the same listbox. Some of the values being sorted have the same name but the other value are different. Also, after an lbSort, the index does not change, just the position in the list box.So if "Hello" was in Position 1 of the listbox before the lbSort is would have an index of 1. After the lbSort, lets say it is in postion 10, it would still have an index of 1. Of course its index within the listbox changes. If your reorder a list box what ever is at the top is at the listboxes index 0.Is this the kind of thing you are after? TEST MISSION rows across are not sorted by any values (although it may look like it with my debug data) but by their relative starting positions. For instance if listbox1 and listbox 2 looked like this at startup 1 6 2 7 3 8 4 9 5 0 After reordering listbox 1, listbox 2 would follow to look like so 1 6 4 9 2 7 5 0 3 8 If this is not what you mean then i am at a loss and you need to explain what your trying to do in more detail. Edited January 28, 2015 by Larrow Share this post Link to post Share on other sites
blckeagls 12 Posted January 29, 2015 (edited) hmm... just getting alot of errors.... Let me just post my code... Error: 20:19:41 Error in expression <_this; _ctrl = ( ( findDisplay 734234 ) displayCtrl _ctrl ); _compareData = _> 20:19:41 Error position: <displayCtrl _ctrl ); _compareData = _> 20:19:41 Error displayctrl: Type Control, expected Number 20:19:41 File A3ResourceWarCl\PlayerScripts\functions.sqf, line 159 DisplayItemforSale.sqf (called when clicked "Primary Weapons Button") private ["_category","_loop","_unsorted","_sorted","_count","_count1","_sortField","_arrayList"]; lbClear 1501; if (GettingInformation) exitWith {}; GettingInformation = true; _category = _this; TraderResults = "XXX"; PlayerGetTraderList = [_category,player]; publicVariableServer "PlayerGetTraderList"; while {(typeName TraderResults) != "ARRAY"} do { lbAdd [1501,"Getting item list from server"]; //systemChat("Getting information from server"); sleep 1; //systemChat(format["TraderResults: %1 -- type: %2 | _category",TraderResults,typeName TraderResults,_category]); if (!GettingInformation) exitWith { GettingInformation = false; }; }; diag_log format["%1",TraderResults]; lbClear 1501; { _transactionID = _x select 0; _className = _x select 1; _quantity = _x select 2; _seller = _x select 3; _price = _x select 4; _sellername = _x select 5; lbAdd [1501,_className]; lbAdd [1502,_quantity]; lbAdd [1503,_price]; lbAdd [1504,_sellername]; lbAdd [1505,_transactionID]; } foreach TraderResults; _display = findDisplay 734234; _ctrl = _display displayctrl 1501; lbSort _ctrl; [] call fnc_storeLBOrders; _ctrl call fnc_updateLBs; GettingInformation = false; MY Diaglog (see idc = 2406): class TraderMenu { idd = 734234; onLoad = "uiNamespace setVariable ['TraderMenu', _this select 0]"; class Controls { class SellBackpackButton: RW_RscButtonMenu { idc = 2400; text = "Backpack Inventory"; //--- ToDo: RW_Localize; x = -3 * GUI_GRID_W + GUI_GRID_X; y = -8.5 * GUI_GRID_H + GUI_GRID_Y; w = 7 * GUI_GRID_W; h = 2 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,0.5}; onButtonClick = "call TraderMenuSellBackPack"; }; class ItemsToSellText: RW_RscText { idc = 1000; text = "Items To Sell"; //--- ToDo: RW_Localize; x = -27.5 * GUI_GRID_W + GUI_GRID_X; y = -9.5 * GUI_GRID_H + GUI_GRID_Y; w = 24 * GUI_GRID_W; h = 1 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,1}; }; class InventoryText: RW_RscText { idc = 1001; text = "Inventory to Sell"; //--- ToDo: RW_Localize; x = -3 * GUI_GRID_W + GUI_GRID_X; y = -9.5 * GUI_GRID_H + GUI_GRID_Y; w = 7 * GUI_GRID_W; h = 1 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,1}; }; class SellVestButton: RW_RscButtonMenu { idc = 2401; text = "Vest Inventory"; //--- ToDo: RW_Localize; x = -3 * GUI_GRID_W + GUI_GRID_X; y = -6 * GUI_GRID_H + GUI_GRID_Y; w = 7 * GUI_GRID_W; h = 2 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,0.5}; onButtonClick = "call TraderMenuSellVest"; }; class SellUniformButton: RW_RscButtonMenu { idc = 2402; text = "Uniform Inventory"; //--- ToDo: RW_Localize; x = -3 * GUI_GRID_W + GUI_GRID_X; y = -3.5 * GUI_GRID_H + GUI_GRID_Y; w = 7 * GUI_GRID_W; h = 2 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,0.5}; onButtonClick = "call TraderMenuSellUniform"; }; class SellVehicleInvButton: RW_RscButtonMenu { idc = 2403; text = "Vehicle Inventory"; //--- ToDo: RW_Localize; x = -3 * GUI_GRID_W + GUI_GRID_X; y = -1 * GUI_GRID_H + GUI_GRID_Y; w = 7 * GUI_GRID_W; h = 2 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,0.5}; onButtonClick = "call TraderMenuSellVehicleInventory"; }; class SellCurrentItems: RW_RscButtonMenu { idc = 2404; text = "Current Items"; //--- ToDo: RW_Localize; x = -3 * GUI_GRID_W + GUI_GRID_X; y = 1.5 * GUI_GRID_H + GUI_GRID_Y; w = 7 * GUI_GRID_W; h = 2 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,0.5}; onButtonClick = "call TraderMenuSellCurrentItems"; }; class SellLastVehicle: RW_RscButtonMenu { idc = 2405; text = "Last Vehicle"; //--- ToDo: RW_Localize; x = -3 * GUI_GRID_W + GUI_GRID_X; y = 4 * GUI_GRID_H + GUI_GRID_Y; w = 7 * GUI_GRID_W; h = 2 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,0.5}; onButtonClick = "call TraderMenuSellLastVehicle"; }; class RscText_1002: RW_RscText { idc = 1002; text = "Items To Buy"; //--- ToDo: RW_Localize; x = 11.5 * GUI_GRID_W + GUI_GRID_X; y = -9.5 * GUI_GRID_H + GUI_GRID_Y; w = 20 * GUI_GRID_W; h = 1 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,1}; }; class RscText_11000002: RW_RscText { idc = 1000002; text = "Trans No."; //--- ToDo: RW_Localize; x = 5.5 * GUI_GRID_W + GUI_GRID_X; y = -9.5 * GUI_GRID_H + GUI_GRID_Y; w = 5 * GUI_GRID_W; h = 1 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,1}; }; class RscText_1006: RW_RscText { idc = 1006; text = "Quantity"; //--- ToDo: RW_Localize; x = 32 * GUI_GRID_W + GUI_GRID_X; y = -9.5 * GUI_GRID_H + GUI_GRID_Y; w = 5.5 * GUI_GRID_W; h = 1 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,1}; }; class RscText_1003: RW_RscText { idc = 1003; text = "Price"; //--- ToDo: RW_Localize; x = 38 * GUI_GRID_W + GUI_GRID_X; y = -9.5 * GUI_GRID_H + GUI_GRID_Y; w = 8.5 * GUI_GRID_W; h = 1 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,1}; }; class RscText_1004: RW_RscText { idc = 1004; text = "Seller"; //--- ToDo: RW_Localize; x = 47 * GUI_GRID_W + GUI_GRID_X; y = -9.5 * GUI_GRID_H + GUI_GRID_Y; w = 10.5 * GUI_GRID_W; h = 1 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,1}; }; class ItemsToBuyInventoryList1: RW_RscListbox { idc = 1501; x = 11.5 * GUI_GRID_W + GUI_GRID_X; y = -8.5 * GUI_GRID_H + GUI_GRID_Y; w = 20 * GUI_GRID_W; h = 43 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,.5}; onLBSelChanged = "if (!DoingSelection) then {[1501] call TradeMenuSelected}"; }; class ItemsToBuyInventoryList5: RW_RscListbox { idc = 1505; x = 5.5 * GUI_GRID_W + GUI_GRID_X; y = -8.5 * GUI_GRID_H + GUI_GRID_Y; w = 5 * GUI_GRID_W; h = 43 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,.5}; onLBSelChanged = "if (!DoingSelection) then {[1501] call TradeMenuSelected}"; }; class ItemsToBuyInventoryList2: RW_RscListbox { idc = 1502; x = 32 * GUI_GRID_W + GUI_GRID_X; y = -8.5 * GUI_GRID_H + GUI_GRID_Y; w = 5.5 * GUI_GRID_W; h = 43 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,.5}; onLBSelChanged = "if (!DoingSelection) then {[1502] call TradeMenuSelected}"; }; class ItemsToBuyInventoryList3: RW_RscListbox { idc = 1503; x = 38 * GUI_GRID_W + GUI_GRID_X; y = -8.5 * GUI_GRID_H + GUI_GRID_Y; w = 8.5 * GUI_GRID_W; h = 43 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,.5}; onLBSelChanged = "if (!DoingSelection) then {[1503] call TradeMenuSelected}"; }; class ItemsToBuyInventoryList4: RW_RscListbox { idc = 1504; x = 47 * GUI_GRID_W + GUI_GRID_X; y = -8.5 * GUI_GRID_H + GUI_GRID_Y; w = 10.5 * GUI_GRID_W; h = 43 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,.5}; onLBSelChanged = "if (!DoingSelection) then {[1504] call TradeMenuSelected}"; }; class RscText_1005: RW_RscText { idc = 1005; text = "Categories"; //--- ToDo: RW_Localize; x = 58 * GUI_GRID_W + GUI_GRID_X; y = -9.5 * GUI_GRID_H + GUI_GRID_Y; w = 9.5 * GUI_GRID_W; h = 1 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,1}; }; class BuyPrimaryWeaponButton: RW_RscButtonMenu { idc = 2406; text = "Primary Weapons"; //--- ToDo: RW_Localize; x = 58 * GUI_GRID_W + GUI_GRID_X; y = -8.5 * GUI_GRID_H + GUI_GRID_Y; w = 9.5 * GUI_GRID_W; h = 2 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,0.5}; onButtonClick = """PrimaryWeapons"" execVM ""\A3ResourceWarCl\diaglogs\traderscripts\buyscripts\DisplayItemsforSale.sqf"""; }; class BuyLauncherButton: RW_RscButtonMenu { idc = 2407; text = "Launcher Weapons"; //--- ToDo: RW_Localize; x = 58 * GUI_GRID_W + GUI_GRID_X; y = -6 * GUI_GRID_H + GUI_GRID_Y; w = 9.5 * GUI_GRID_W; h = 2 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,0.5}; }; class BuyHandgunButton: RW_RscButtonMenu { idc = 2408; text = "Handgun Weapons"; //--- ToDo: RW_Localize; x = 58 * GUI_GRID_W + GUI_GRID_X; y = -3.5 * GUI_GRID_H + GUI_GRID_Y; w = 9.5 * GUI_GRID_W; h = 2 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,0.5}; }; class BuyMagazineButton: RW_RscButtonMenu { idc = 2409; text = "Magazines"; //--- ToDo: RW_Localize; x = 58 * GUI_GRID_W + GUI_GRID_X; y = -1 * GUI_GRID_H + GUI_GRID_Y; w = 9.5 * GUI_GRID_W; h = 2 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,0.5}; }; class BuyItemsButton: RW_RscButtonMenu { idc = 2410; ttext = "General Items"; //--- ToDo: RW_Localize; x = 58 * GUI_GRID_W + GUI_GRID_X; y = 4 * GUI_GRID_H + GUI_GRID_Y; w = 9.5 * GUI_GRID_W; h = 2 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,0.5}; }; class ButExplosivesButton: RW_RscButtonMenu { idc = 2411; text = "Explosives"; //--- ToDo: RW_Localize; x = 58 * GUI_GRID_W + GUI_GRID_X; y = 1.5 * GUI_GRID_H + GUI_GRID_Y; w = 9.5 * GUI_GRID_W; h = 2 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,0.5}; }; class ItemsToSellList: RW_RscListbox { idc = 1500; x = -27.5 * GUI_GRID_W + GUI_GRID_X; y = -8.5 * GUI_GRID_H + GUI_GRID_Y; w = 24 * GUI_GRID_W; h = 42.5 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,.5}; onLBSelChanged = "[_this] call SellChangeQuantity"; }; class BuyWoodButton: RW_RscButtonMenu { idc = 2412; text = "Wood"; //--- ToDo: RW_Localize; x = 58 * GUI_GRID_W + GUI_GRID_X; y = 17.5 * GUI_GRID_H + GUI_GRID_Y; w = 9.5 * GUI_GRID_W; h = 1 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,0.5}; }; class BuyStoneButton: RW_RscButtonMenu { idc = 2413; text = "Stone"; //--- ToDo: RW_Localize; x = 58 * GUI_GRID_W + GUI_GRID_X; y = 19 * GUI_GRID_H + GUI_GRID_Y; w = 9.5 * GUI_GRID_W; h = 1 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,0.5}; }; class BuySiliconButton: RW_RscButtonMenu { idc = 2414; text = "Silicon"; //--- ToDo: RW_Localize; x = 58 * GUI_GRID_W + GUI_GRID_X; y = 20.5 * GUI_GRID_H + GUI_GRID_Y; w = 9.5 * GUI_GRID_W; h = 1 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,0.5}; }; class BuyPlasticButton: RW_RscButtonMenu { idc = 2415; text = "Plastic"; //--- ToDo: RW_Localize; x = 58 * GUI_GRID_W + GUI_GRID_X; y = 22 * GUI_GRID_H + GUI_GRID_Y; w = 9.5 * GUI_GRID_W; h = 1 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,0.5}; }; class BuyClothButton: RW_RscButtonMenu { idc = 2416; text = "Cloth"; //--- ToDo: RW_Localize; x = 58 * GUI_GRID_W + GUI_GRID_X; y = 23.5 * GUI_GRID_H + GUI_GRID_Y; w = 9.5 * GUI_GRID_W; h = 1 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,0.5}; }; class BuyMetalButton: RW_RscButtonMenu { idc = 2417; text = "Metal"; //--- ToDo: RW_Localize; x = 58 * GUI_GRID_W + GUI_GRID_X; y = 25 * GUI_GRID_H + GUI_GRID_Y; w = 9.5 * GUI_GRID_W; h = 1 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,0.5}; }; class BuyChemicalButton: RW_RscButtonMenu { idc = 2418; text = "Chemicals"; //--- ToDo: RW_Localize; x = 58 * GUI_GRID_W + GUI_GRID_X; y = 26.5 * GUI_GRID_H + GUI_GRID_Y; w = 9.5 * GUI_GRID_W; h = 1 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,0.5}; }; class BuyGunpowderButton: RW_RscButtonMenu { idc = 2419; text = "Gunpowder"; //--- ToDo: RW_Localize; x = 58 * GUI_GRID_W + GUI_GRID_X; y = 28 * GUI_GRID_H + GUI_GRID_Y; w = 9.5 * GUI_GRID_W; h = 1 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,0.5}; }; class BuyRubberButton: RW_RscButtonMenu { idc = 2420; text = "Rubber"; //--- ToDo: RW_Localize; x = 58 * GUI_GRID_W + GUI_GRID_X; y = 29.5 * GUI_GRID_H + GUI_GRID_Y; w = 9.5 * GUI_GRID_W; h = 1 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,0.5}; }; class BuyOilButton: RW_RscButtonMenu { idc = 2421; text = "Oil"; //--- ToDo: RW_Localize; x = 58 * GUI_GRID_W + GUI_GRID_X; y = 31 * GUI_GRID_H + GUI_GRID_Y; w = 9.5 * GUI_GRID_W; h = 1 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,0.5}; }; class BuyVehicleButton: RW_RscButtonMenu { idc = 2422; text = "Vehicles"; //--- ToDo: RW_Localize; x = 58 * GUI_GRID_W + GUI_GRID_X; y = 6.5 * GUI_GRID_H + GUI_GRID_Y; w = 9.5 * GUI_GRID_W; h = 2 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,0.5}; }; class RscText_1007: RW_RscText { idc = 1007; text = "Resources"; //--- ToDo: RW_Localize; x = 58 * GUI_GRID_W + GUI_GRID_X; y = 16.5 * GUI_GRID_H + GUI_GRID_Y; w = 9.5 * GUI_GRID_W; h = 1 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,1}; }; class SellPrice: RW_RscEdit { idc = 1400; text = "1"; //--- ToDo: RW_Localize; x = -3 * GUI_GRID_W + GUI_GRID_X; y = 28 * GUI_GRID_H + GUI_GRID_Y; w = 7 * GUI_GRID_W; h = 1 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,1}; colorActive[] = {-1,-1,-1,0.5}; }; class RscText_1008: RW_RscText { idc = 1008; text = "Sell Price"; //--- ToDo: RW_Localize; x = -3 * GUI_GRID_W + GUI_GRID_X; y = 27 * GUI_GRID_H + GUI_GRID_Y; w = 7 * GUI_GRID_W; h = 1 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,1}; }; class SellButton: RW_RscButtonMenu { idc = 1600; text = "Sell"; //--- ToDo: RW_Localize; x = -3 * GUI_GRID_W + GUI_GRID_X; y = 32 * GUI_GRID_H + GUI_GRID_Y; w = 7 * GUI_GRID_W; h = 2 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,0.7}; onButtonClick = "call TraderSell"; }; class IGUIBack_2200: RW_IGUIBack { idc = 2200; x = 0.340156 * safezoneW + safezoneX; y = -0.00599999 * safezoneH + safezoneY; w = 0.004125 * safezoneW; h = 1.012 * safezoneH; colorBackground[] = {-1,-1,-1,1}; colorActive[] = {-1,-1,-1,1}; }; class BuyButton: RW_RscButtonMenu { idc = 1601; text = "Buy"; //--- ToDo: RW_Localize; x = 58 * GUI_GRID_W + GUI_GRID_X; y = 32.5 * GUI_GRID_H + GUI_GRID_Y; w = 9.5 * GUI_GRID_W; h = 2 * GUI_GRID_H; font = "puristaMedium"; }; /* class BuyItemsButton: RW_RscButtonMenu { idc = 2433; text = "General Items"; //--- ToDo: RW_Localize; x = 58 * GUI_GRID_W + GUI_GRID_X; y = 9 * GUI_GRID_H + GUI_GRID_Y; w = 9.5 * GUI_GRID_W; h = 2 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,0.5}; }; */ class RscText_1010: RW_RscText { idc = 1010; text = "Quantity"; //--- ToDo: RW_Localize; x = -3 * GUI_GRID_W + GUI_GRID_X; y = 29.5 * GUI_GRID_H + GUI_GRID_Y; w = 7 * GUI_GRID_W; h = 1 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,1}; }; class SellQuantity: RW_RscEdit { idc = 1401; text = "1"; //--- ToDo: RW_Localize; x = -3 * GUI_GRID_W + GUI_GRID_X; y = 30.5 * GUI_GRID_H + GUI_GRID_Y; w = 7 * GUI_GRID_W; h = 1 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {1,1,1,1}; colorActive[] = {1,1,1,0.5}; }; class SellResourceButton: RW_RscButtonMenu { idc = 2423; text = "Resources"; //--- ToDo: RW_Localize; x = -3 * GUI_GRID_W + GUI_GRID_X; y = 6.5 * GUI_GRID_H + GUI_GRID_Y; w = 7 * GUI_GRID_W; h = 2 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,0.5}; onButtonClick = "call TraderMenuSellResources"; }; class SellVehicleResourceButton: RW_RscButtonMenu { idc = 2423; text = "Vehicle Resources"; //--- ToDo: RW_Localize; x = -3 * GUI_GRID_W + GUI_GRID_X; y = 9 * GUI_GRID_H + GUI_GRID_Y; w = 7 * GUI_GRID_W; h = 2 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,0.5}; onButtonClick = "call TraderMenuSellVehicleResources"; }; class RscText_1009: RW_RscText { idc = 1009; text = "Put Items Here:"; //--- ToDo: RW_Localize; x = 58 * GUI_GRID_W + GUI_GRID_X; y = 12.5 * GUI_GRID_H + GUI_GRID_Y; w = 9.5 * GUI_GRID_W; h = 1 * GUI_GRID_H; font = "puristaMedium"; colorBackground[] = {-1,-1,-1,1}; }; class RscCombo_2100: RW_RscCombo { idc = 2100; x = 58 * GUI_GRID_W + GUI_GRID_X; y = 13.5 * GUI_GRID_H + GUI_GRID_Y; w = 9.5 * GUI_GRID_W; h = 1 * GUI_GRID_H; font = "puristaMedium"; }; }; }; Value for "TraderResults" [ ["1","C_Van_01_transport_F","1","76561197962932563","1","NotAvailable"],["2","B_Carryall_oli","1","76561197962932563","2","NotAvailable"],["3","Wood","30","76561197962932563","3","NotAvailable"],["4","FirstAidKit","1","76561197962932563","4","NotAvailable"],["5","FirstAidKit","1","76561197962932563","5","NotAvailable"],["6","150Rnd_762x51_Box_Tracer","1","76561197962932563","6","NotAvailable"],["7","150Rnd_762x51_Box_Tracer","1","76561197962932563","7","NotAvailable"],["8","150Rnd_762x51_Box_Tracer","1","76561197962932563","8","NotAvailable"],["9","150Rnd_762x51_Box_Tracer","1","76561197962932563","9","NotAvailable"],["10","150Rnd_762x51_Box_Tracer","1","76561197962932563","10","NotAvailable"],["11","150Rnd_762x51_Box_Tracer","1","76561197962932563","11","NotAvailable"],["12","150Rnd_762x51_Box_Tracer","1","76561197962932563","12","NotAvailable"],["13","150Rnd_762x51_Box_Tracer","1","76561197962932563","13","NotAvailable"] ] I want to sort 1502,1503,1504,1504 the exact same way as 1501.. If I could get the order 1501 is sorted in, i.e. [1,5,2,6,7,....] then I could easily sort the rest in that order with: { lbadd[1502,(TraderResults select _x) select 2]; lbadd[1503,(TraderResults select _x) select 3]; lbadd[1504,(TraderResults select _x) select 4]; lbadd[1505,(TraderResults select _x) select 5]; } foreach [1,5,2,6,7,....]; Edited January 29, 2015 by blckeagls Share this post Link to post Share on other sites
Larrow 2821 Posted January 29, 2015 (edited) DisplayItemforSale.sqf private ["_category","_loop","_unsorted","_sorted","_count","_count1","_sortField","_arrayList"]; lbClear 1501; if (GettingInformation) exitWith {}; GettingInformation = true; _category = _this; TraderResults = "XXX"; PlayerGetTraderList = [_category,player]; publicVariableServer "PlayerGetTraderList"; while {(typeName TraderResults) != "ARRAY"} do { lbAdd [1501,"Getting item list from server"]; //systemChat("Getting information from server"); sleep 1; //systemChat(format["TraderResults: %1 -- type: %2 | _category",TraderResults,typeName TraderResults,_category]); if (!GettingInformation) exitWith { GettingInformation = false; }; }; diag_log format["%1",TraderResults]; //Clear the list box lbClear 1501; //Fill 1501 with TradeResults classnames { _className = _x select 1; //Get index classname is added at _index = lbAdd [1501,_className]; //Store index to listbox Value lbSetValue [ 1501, _index, _forEachIndex ]; } forEach TraderResults; //Sort 1501 _display = findDisplay 734234; _ctrl = _display displayctrl 1501; lbSort _ctrl; //Fill other listboxes according to 1501 sort order for "_i" from 0 to ( count TraderResults ) -1 do { //Retrieve original index from value _index = lbValue [ 1501, _i ]; //Get corresponding tradeResults data _data = TraderResults select _index; //Get info from data _transactionID = _data select 0; _quantity = _data select 2; _seller = _data select 3; _price = _data select 4; _sellername = _data select 5; //Add data to other listboxes lbAdd [ 1502, _quantity ]; lbAdd [ 1503, _price ]; lbAdd [ 1504, _sellername ]; lbAdd [ 1505, _transactionID ]; }; GettingInformation = false; Edited January 29, 2015 by Larrow Share this post Link to post Share on other sites
blckeagls 12 Posted January 29, 2015 Outstanding man! Thanks for all your help! Share this post Link to post Share on other sites