Skip to main content
1-Visitor
Feb 12, 2015 3:31 AM UTC
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
Feb 12, 2015 5:47 AM UTC

VV.png

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

Translate
1-Visitor
Feb 12, 2015 6:36 AM UTC

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
Feb 12, 2015 7:08 AM UTC

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
Feb 12, 2015 7:30 PM UTC

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
Feb 13, 2015 6:41 AM UTC

One KISS-program

Sort.png

PS

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

Translate