Problem 1056. Partial sorting algorithm
Argh! The 'mod sorting' has me flummoxed!
Is this broken? On my machine at least the anonymous comparison function is not found in profile('info').
Also, note that in the "mod comparison" case, the ordering has some unintuitive properties. For instance, 30 > 6 since 30 divides 6 and 30 ~ 20 since neither divides the other, but 20 ~ 6 for the same reason, meaning that ~ is not transitive using this comparison function.
A final issue: the comparison the "mod comparison" case does not match the description in the problem. The problem states that this function should return "true [if] element m should be ranked higher than element n" (m > n), but in this test case, the function also returns true when m is equal to n (and so implements m >= n).
Solution CommentsShow comments
Problem Recent Solvers9
Return a list sorted by number of occurrences
Find state names that end with the letter A
Find best placement for ordered dominoes (harder)
Create a random logical vector of N elements of which M are true.
More from this Author5
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!