You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* @param sortAlgorithm the sort algorithm either {@link UiPager#A_Z} or {@link UiPager#Z_A}.
240
241
* @return the new sorted String in the shape of Collection List.
241
-
* @throws Exception if process is interrupted or -1 is returned.
242
242
* @apiNote you will need to loop over this list to provide the uiStates with new update.
243
243
*/
244
-
public <MextendsPageDataModel> M[] sort(M[] list, intsortAlgorithm) throwsException{
244
+
public <MextendsPageDataModel> M[] sort(M[] list, intsortAlgorithm) {
245
245
//to apply the sort change as an external final change on a list copy (warning : ->Internal List change(positions or items count or items values) = Malicious Activity
246
246
finalM[] copy = Arrays.copyOf(list, list.length);
247
-
MtempPointer;
248
-
//main String List looping
249
-
for (inti = 0; i < copy.length; i++) {
250
-
//looping over the String again to compare each one String member var with the sequence of the String member vars after that item
251
-
for(intj = i+1; j < copy.length; j++ ){
252
-
//sort from A-Z ascendingly
253
-
if(sortAlgorithm == A_Z){
254
-
//compare 2 strings lexicographically based on their characters, if the (string object > the argument string) then compareTo returns 1
255
-
if ( copy[i].getSortingData().toLowerCase().compareTo(copy[j].getSortingData().toLowerCase()) > 0 ){
256
-
//then swap list[i] & list[j] because list[i] is after the list[k]
257
-
//store the list[i] inside the tempPointer for later access
258
-
tempPointer = copy[i];
259
-
//get the list[i] after
260
-
copy[i] = copy[j];
261
-
//get the list[j] before
262
-
copy[j] = tempPointer;
263
-
}
264
-
}elseif(sortAlgorithm == Z_A){
265
-
//compare 2 strings lexicographically based on their characters, if the (string object < the argument string) then compareTo returns -1
266
-
if ( copy[i].getSortingData().toLowerCase().compareTo(copy[j].getSortingData().toLowerCase()) < 0){
267
-
//then swap list[i] & list[j] because list[i] is before the list[k]
268
-
//store the list[j] inside the tempPointer for later access
269
-
tempPointer = copy[j];
270
-
//get the list[j] before
271
-
copy[j] = copy[i];
272
-
//get the list[i] after
273
-
copy[i] = tempPointer;
274
-
}
275
-
}
247
+
MtempPointer;
248
+
//main String List looping
249
+
for (inti = 0; i < copy.length; i++) {
250
+
//looping over the String again to compare each one String member var with the sequence of the String member vars after that item
251
+
for(intj = i+1; j < copy.length; j++ ){
252
+
//sort from A-Z ascendingly
253
+
if(sortAlgorithm == A_Z){
254
+
//compare 2 strings lexicographically based on their characters, if the (string object > the argument string) then compareTo returns 1
255
+
if ( copy[i].getSortingData().toLowerCase().compareTo(copy[j].getSortingData().toLowerCase()) > 0 ){
256
+
//then swap list[i] & list[j] because list[i] is after the list[k]
257
+
//store the list[i] inside the tempPointer for later access
258
+
tempPointer = copy[i];
259
+
//get the list[i] after
260
+
copy[i] = copy[j];
261
+
//get the list[j] before
262
+
copy[j] = tempPointer;
263
+
}
264
+
}elseif(sortAlgorithm == Z_A){
265
+
//compare 2 strings lexicographically based on their characters, if the (string object < the argument string) then compareTo returns -1
266
+
if ( copy[i].getSortingData().toLowerCase().compareTo(copy[j].getSortingData().toLowerCase()) < 0){
267
+
//then swap list[i] & list[j] because list[i] is before the list[k]
268
+
//store the list[j] inside the tempPointer for later access
0 commit comments