|
|
Home » U++ Library support » U++ Core » stable sort bug.. or looks like it
stable sort bug.. or looks like it [message #48123] |
Sun, 21 May 2017 22:30 |
aftershock
Messages: 143 Registered: May 2008
|
Experienced Member |
|
|
Have a look
VectorMap<String, int> involved_nodes;
DUMPM ( involved_nodes );
StableSort ( involved_nodes.Begin(), involved_nodes.End(), lip );
DUMPM ( involved_nodes );
Stable sort does not seem copy key value pairs correctly for maps.
before
involved_nodes:
[0] = (tester_withdraw_when) 0
[1] = (tester_withdraw_amount) 2
[2] = (tester_balance) 3
[3] = (trading_buy_open_start_hour) 12
[4] = (trading_buy_open_end_hour) 13
[5] = (trading_sell_open_start_hour) 18
[6] = (trading_sell_open_end_hour) 19
[7] = (buy_closewhenprofit) 38
[8] = (buy_stepsize) 43
[9] = (buy_stopdistance) 47
[10] = (sell_stepsize) 51
[11] = (sell_closewhenprofit) 52
[12] = (buy_close_after_minutes) 180
[13] = (sell_close_after_minutes) 181
[14] = (sell_stopdistance) 216
[15] = (buy_stop_fallback) 221
[16] = (sell_stop_fallback) 225
[17] = (buy_rsi_timeframe) 229
[18] = (sell_rsi_timeframe) 230
[19] = (buy_rsi_upper_limit) 367
[20] = (sell_rsi_lower_limit) 368
after incorrect result
involved_nodes:
[0] = (tester_withdraw_when) 3
[1] = (tester_withdraw_amount) 0
[2] = (tester_balance) 2
[3] = (trading_buy_open_start_hour) 19
[4] = (trading_buy_open_end_hour) 13
[5] = (trading_sell_open_start_hour) 18
[6] = (trading_sell_open_end_hour) 12
[7] = (buy_closewhenprofit) 38
[8] = (buy_stepsize) 47
[9] = (buy_stopdistance) 51
[10] = (sell_stepsize) 216
[11] = (sell_closewhenprofit) 221
[12] = (buy_close_after_minutes) 229
[13] = (sell_close_after_minutes) 43
[14] = (sell_stopdistance) 52
[15] = (buy_stop_fallback) 180
[16] = (sell_stop_fallback) 181
[17] = (buy_rsi_timeframe) 225
[18] = (sell_rsi_timeframe) 230
[19] = (buy_rsi_upper_limit) 367
[20] = (sell_rsi_lower_limit) 368
This is what it should be.....
involved_nodes:
[0] = (tester_withdraw_when) 0
[1] = (tester_withdraw_amount) 2
[2] = (tester_balance) 3
[3] = (trading_buy_open_start_hour) 12
[4] = (trading_buy_open_end_hour) 13
[5] = (trading_sell_open_start_hour) 18
[6] = (trading_sell_open_end_hour) 19
[7] = (buy_closewhenprofit) 38
[8] = (buy_stepsize) 43
[9] = (buy_stopdistance) 47
[10] = (sell_stepsize) 51
[11] = (sell_closewhenprofit) 52
[12] = (buy_close_after_minutes) 180
[13] = (sell_close_after_minutes) 181
[14] = (sell_stopdistance) 216
[15] = (buy_stop_fallback) 221
[16] = (sell_stop_fallback) 225
[17] = (buy_rsi_timeframe) 229
[18] = (sell_rsi_timeframe) 230
[19] = (buy_rsi_upper_limit) 367
[20] = (sell_rsi_lower_limit) 368
Thanks.. Can you fix this?
A.
|
|
|
Re: stable sort bug.. or looks like it [message #48130 is a reply to message #48123] |
Mon, 22 May 2017 12:00 |
|
mirek
Messages: 14039 Registered: November 2005
|
Ultimate Member |
|
|
aftershock wrote on Sun, 21 May 2017 22:30Have a look
VectorMap<String, int> involved_nodes;
DUMPM ( involved_nodes );
StableSort ( involved_nodes.Begin(), involved_nodes.End(), lip );
DUMPM ( involved_nodes );
Stable sort does not seem copy key value pairs correctly for maps.
All Sorts, when used like this, only sort values, as begin/end here return iterators to values only (the value subvector).
I think that to do what you need, you can use [Stable]SortByValues and then StableSortByKeys.
(Perhaps we might add [Stable]SortBy[KeysAndValues|ValuesAndKeys] in future...)
Mirek
[Updated on: Mon, 22 May 2017 12:02] Report message to a moderator
|
|
|
|
|
|
|
|
Goto Forum:
Current Time: Fri Sep 20 12:11:15 CEST 2024
Total time taken to generate the page: 0.09733 seconds
|
|
|