Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int sortValues[4] = { 50, 150, 40, 80 };
- //-------------------------
- void setup()
- {
- Serial.begin(9600);
- }
- //------------------------
- void loop()
- {
- sort(sortValues, 4);
- for (int i = 0; i < 4; i++)
- {
- Serial.print(sortValues[i]);
- Serial.print(",");
- }
- Serial.println(" ");
- delay(500);
- }
- //----------------------------
- void sort(int a[], int size)
- {
- for (int i = 0; i < (size - 1); i++)
- {
- for (int o = 0; o < (size - (i + 1)); o++)
- {
- if (a[o] > a[o + 1])
- {
- int t = a[o];
- a[o] = a[o + 1];
- a[o + 1] = t;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement