c++ - Alphabetically sorting an array piece by piece -
i'm trying sort array of strings alphabetically have same frequency input file. start looping through entire array, , set indices @ points grouping of words have same frequencies. insertion sort between given indices. here's function:
//insertion sort array, checking same frequencies , moving words alphabetically downwards int startidx = 0; int endidx = 0; for(int k = 0; k < freq.length(); k++) { if(freq.at(startidx) == freq.at(k)) { endidx++; } else { insertionsort(startidx, endidx); //sort string array @ given indices startidx = endidx = k; } }
the function isn't sorting array...it works when indices set 0 length(), or other arbitrarily set values otherwise doesn't work.
c++ sorting character-arrays
No comments:
Post a Comment