Question: What's with MTM[sort]?

It took me a while to figure out what was causing this unusual sort result;

I loaded the MTM package because I want to convert numbers to integers for indexing. This sort result seem like it could be a bug.

Sort a List of Floats

NULL

with(MTM):

NULL

x := [1/3, 0, 4] = [1/3, 0, 4]``

``

sort(x) = [0, 1/3, 4]``

NULL

f_x_MTM := [seq(convert([x[n], n], float), n = 1 .. 3)] = [[.3333333333, 1.], [0., 2.], [4., 3.]]NULL

sort(f_x_MTM) = [[.3333333333, 1.], [0., 2.], [4., 3.]]NULL

NULL

unwith(MTM):

f_x := [seq(convert([x[n], n], float), n = 1 .. 3)] = [[.3333333333, 1.], [0., 2.], [4., 3.]]

NULL

sort(f_x) = [[0., 2.], [.3333333333, 1.], [4., 3.]]

``

 

Download MTMsort.mw

Please Wait...