Redmine#2516 and Redmine#3132: numeric, IPv4, IPv6, and MAC address sort

Revised pull request.  Incorporates https://github.com/cfengine/core/pull/844 (@cduclos revisions to `isIPAddress`).

Resolves https://cfengine.com/dev/issues/3132 and https://cfengine.com/dev/issues/2516

Acceptance test included.  Will write documentation as soon as this is accepted.