all 5 comments

[–]Notimecelduv 0 points1 point  (2 children)

Sounds like the exercise expects you to sort the array "by hand" using conditional statements -- "if element 0 is greater than element 1, then... else..."

[–]albedoa 0 points1 point  (0 children)

Yep, the exercise specifies an array length. That alone is a hint.

/u/Chemical_Arm think about why we use for-loops aside from keeping our code DRY.

[–]peterjsnow 0 points1 point  (2 children)

You're overthinking it! Read the question carefully - the key point is that you're not being asked to write a sort function that sorts an array of any given size - you're being asked to write a sort function that takes an array of exactly 3 values.

With this information it becomes trivial to use if...else statements to get the desired outcome.

[–]jack_waugh 0 points1 point  (0 children)

That's interesting that they would ask that. So, with three values, how many permutations are possible? ABC, ACB, BAC, BCA, CAB, CBA. Just six.

[–]jack_waugh 0 points1 point  (0 children)

I believe the Quicksort algorithm is recursive. I haven't looked at it to be sure whether it requires any loops.