## -*- texinfo -*-
## @deftypefn {Function File} {@var{s} =} esort(@var{p})
## @deftypefnx {Function File} {[@var{s}, @var{ndx}] =} esort(@var{p})
## Sort continuous-time poles by real part (in decreasing order).
##
## @strong{Inputs}
## @table @var
## @item p
## Input vector containing continuous-time poles.
## @end table
##
## @strong{Outputs}
## @table @var
## @item s
## Vector with sorted eigenvalues.
## @item ndx
## Vector containing the indices used in the sort.
## @end table
##
## @seealso{dsort, eig, pole, pzmap, sort, zero}
## @end deftypefn

## Author: Mark Bronsfeld <m.brnsfld@googlemail.com>
## Created: December 2016
## Version: 0.1

function [s, ndx] = esort(p)
        if(nargin == 1)
                if(!isvector(p))
                error("esort: argument must be a vector");
                endif
        else
                print_usage();
        endif

        [p_sorted, ndx] = sort(real(p), 'descend');     % unused variable "p_sorted" not replaced with "~" because of backwards compatibility (<2009)
        s = p(ndx);
endfunction
