Skip to main content
1-Visitor
Question

Vectors and Matrics

If we have an arbitrary vector (V) like the one shown. Using Mathcad we want to order data from lowest to highest like the one shown on right. How would we do that?

image is attached

8 replies

24-Ruby IV

VV.png

(My answer as long as everyone in Europe and America are sleeping)

Translate
1-Visitor

Thanks for answering, however the main idea is to move down through the array comparing adjacent pairs and swapping the values if they are out of order. can you do it this way?

Translate
24-Ruby IV

Zack Alhashim wrote:

Thanks for answering, however the main idea is to move down through the array comparing adjacent pairs and swapping the values if they are out of order. can you do it this way?

Would you like to know how does the built-in function sort work?

Translate
Werner_E
25-Diamond I

In case you have difficulties finding a decent sorting algorithm to implement (which is very unlikely, I guess), I'd recommend this site: http://www.sorting-algorithms.com/

You can compare different algorithms, watch animations and look at the algorithm's pseudo code.

Find attached an attempt to create that kind of animiation in Mathcad for the bubble sort algorithm.

You may play around with the attached sheet, but the sort routine is protected for obvious reasons.

Translate
24-Ruby IV

One KISS-program

Sort.png

PS

We need swap(a, b) function (a procedure) in Mathcad!?

Translate