[changed subject to make it easier to find]
Ah--figured it out when I looked at the test header.
Here's the order that works for the header file:
#include <stan/math/prim/mat/fun/Eigen.hpp>
#include <stan/math/prim/scal/err/check_not_nan.hpp>
#include <algorithm>
and the test file:
#include <stan/math/prim/mat.hpp>
#include <stan/math/prim/arr.hpp>
#include <gtest/gtest.h>
#include <limits>
#include <stdexcept>
If you swap mat.hpp and arr.hpp in the test file, the tests
fail. But in this order, they're OK.
I take back everyting I said about external files including
things piecemeal. If we ever get around to documenting the
math lib, we're going to have to make the order of header includes
clear to users.
This is all for the nan sorting issue. That led me down another
rabbit ole because the function was independently defined in
rev, fwd, and mix when it didn't need to be and the matrix and
array versions were both defined in the matrix path. I'm
trying to move things to matching our conventions for path layout
when I hit them. Looks like we may still have a ways to go.
- Bob