noknown 0 Posted August 23, 2011 Hi All! Does anybody know about ready function which can roll an array with grouping and summing values. Example 2D array BEFORE: Name Orders John 25 Smith 30 Adams 20 John 10 Adams 30 Example 2D array AFTER: Name Orders John 35 Smith 30 Adams 50 I could write my own, but if somewhere is ready to function - what a shame to spend time. Sorry, if this question is very simple. I'm beginning programmer. And sorry for my english. Thanks for for answers (if they will) Share this post Link to post Share on other sites
JohnOne 1,603 Posted August 23, 2011 I've never seen a UDF specifically for that (not saying there isnt one), but I'm sure there will be a combination of UDFs you could use to achieve it. My personal thought are that it would take you longer to learn the ready functions and implement them, than it would to make your own custom function. And you would learn more writing your own. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Share this post Link to post Share on other sites
noknown 0 Posted August 23, 2011 I've never seen a UDF specifically for that (not saying there isnt one), but I'm sure there will be a combination of UDFs you could use to achieve it.My personal thought are that it would take you longer to learn the ready functions and implement them, than it would to make your own custom function. And you would learn more writing your own.Thank u! Share this post Link to post Share on other sites
Spiff59 54 Posted August 23, 2011 (edited) It makes life easier to process arrays in reverse order when you're likely to be doing deletions to the array. Something like: #include <Array.au3> Global $array[6][2] = [["John",25],["Smith",30],["Adams",20],["John",10],["Adams",30],["John",5]] _ArrayDisplay($array) For $x = UBound($array) - 1 to 1 Step -1 For $y = $x - 1 to 0 Step -1 If $array[$x][0] = $array[$y][0] Then $array[$y][1] += $array[$x][1] _ArrayDelete($array, $x) ExitLoop EndIf Next Next _ArrayDisplay($array) Edited August 23, 2011 by Spiff59 Share this post Link to post Share on other sites
noknown 0 Posted August 23, 2011 It makes life easier to process arrays in reverse order when you're likely to be doing deletions to the array.Thank u very much! Share this post Link to post Share on other sites