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
//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
240
+
finalString[] copy = list;
243
241
returnExecutors.callable(() -> {
244
242
StringtempPointer = "";
245
243
//main String List looping
246
-
for (inti = 0; i < list.length; i++) {
244
+
for (inti = 0; i < copy.length; i++) {
247
245
//looping over the String again to compare each one String member var with the sequence of the String member vars after that item
248
-
for(intj = i+1; j < list.length; j++ ){
246
+
for(intj = i+1; j < copy.length; j++ ){
249
247
//sort from A-Z ascendingly
250
248
if(sortAlgorithm == A_Z){
251
249
//compare 2 strings lexicographically based on their characters, if the (string object > the argument string) then compareTo returns 1
252
-
if ( list[i].toLowerCase().compareTo(list[j].toLowerCase()) > 0 ){
250
+
if ( copy[i].toLowerCase().compareTo(copy[j].toLowerCase()) > 0 ){
253
251
//format the pointer
254
252
tempPointer = "";
255
253
//then swap list[i] & list[j] because list[i] is after the list[k]
256
254
//store the list[i] inside the tempPointer for later access
257
-
tempPointer = list[i];
255
+
tempPointer = copy[i];
258
256
//get the list[i] after
259
-
list[i] = list[j];
257
+
copy[i] = copy[j];
260
258
//get the list[j] before
261
-
list[j] = tempPointer;
259
+
copy[j] = tempPointer;
262
260
}
263
261
}elseif(sortAlgorithm == Z_A){
264
262
//compare 2 strings lexicographically based on their characters, if the (string object < the argument string) then compareTo returns -1
265
-
if ( list[i].toLowerCase().compareTo(list[j].toLowerCase()) < 0){
263
+
if ( copy[i].toLowerCase().compareTo(copy[j].toLowerCase()) < 0){
266
264
//format the pointer
267
265
tempPointer = "";
268
266
//then swap list[i] & list[j] because list[i] is before the list[k]
269
267
//store the list[j] inside the tempPointer for later access
0 commit comments