35 lines
901 B
Java
35 lines
901 B
Java
package domain;
|
|
|
|
import org.junit.jupiter.params.shadow.com.univocity.parsers.common.fields.ColumnMapping;
|
|
import robot.interfaces.Sorting;
|
|
|
|
import java.util.Arrays;
|
|
import java.util.Collection;
|
|
import java.util.Collections;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
public class C3PO extends RobotBasics implements Sorting {
|
|
public C3PO(int id, String name){
|
|
super(id, name);
|
|
}
|
|
|
|
//@Override
|
|
public String sorting(int[] arr) {
|
|
//Insertionsort
|
|
for(int i=1;i<arr.length;i++){
|
|
int b = i-1;
|
|
int key = arr[i];
|
|
while(b>=0 && arr[b]>key) arr[b+1] = arr[b--];
|
|
arr[b+1] = key;
|
|
}
|
|
//Writing all values of the array into a String
|
|
String result = "" + arr[0];
|
|
if(arr.length > 1) {
|
|
for (int i = 1; i < arr.length; i++) {
|
|
result += ";" + arr[i];
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
}
|