Questions and suggestions about ArrayFindString and sorting natives
Hi, have a few questions about the sort natives and ArrayFindString native:
1. Recently I came across a problem with sorting an array that has a lot of equal items. After the sorting, the items are being "shifted" down for some reason and I don't know if it's supposed to be like this. Here's an example code:
Spoiler
Result: Quote:
If all the items are equal (according to my sort algorithm), so why does the index change? shouldn't it stay the exact same? Also -- on a side note, would be really cool to have a cmp(x,y) native/stock inside a default include file, just like floatcmp has one. 2. ArrayFindString checking contain instead of equal and is case sensitive. Basically this makes this native useless 90% of the the times, it's to dangerous to use it if it's acting like 'contain' (instead of 'equal') and it's not very practical. If I have an array of SteamIDS, I might get STEAM_0:111156 when searching for STEAM_0:1111. If I have an array of maps I might get de_dust2 when searching for de_dust. Would be very nice to have a parameter for case insensitive/case sensitive and maybe a param/second native if to act like 'contain' or 'equal'. Thank you for keeping this project alive, everyone. |
Re: Questions and suggestions about ArrayFindString and sorting natives
SortCustom1D(and other natives probably) uses qsort to perform the actual sorting.
http://www.cplusplus.com/reference/cstdlib/qsort/ Documentation says the order of equal elements is undefined, this is why. |
Re: Questions and suggestions about ArrayFindString and sorting natives
Quote:
So basically if i'll do 'return 1' for equal items it will work as I expected. |
Re: Questions and suggestions about ArrayFindString and sorting natives
You are supposed to compare the elements.
Code:
|
Re: Questions and suggestions about ArrayFindString and sorting natives
Quote:
Some comments on my 2nd suggestion? :) |
All times are GMT -4. The time now is 09:05. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.