function s = reorderdesignoptsstruct(~,s,varargin)
%REORDERDESIGNOPTSSTRUCT Abstract method.

%   Copyright 1999-2015 The MathWorks, Inc.

%Reorder the structure to maintain backwards compatibility with UDD

b = {...
  'FilterStructure',...
  'Norm',...
  'DensityFactor',...
  'MaxPoleRadius',...
  'InitNorm',...
  'InitNum',...
  'InitDen',...
  'MinPhase',...
  'MaxPhase',...
  'ZeroPhase',...
  'MinOrder',...
  'InitOrder',...
  'SOSScaleNorm',...
  'SOSScaleOpts',...
  'Wstop1',...
  'Wpass',...
  'Wstop2',...
  'Wpass1',...
  'Wstop',...
  'Wpass2',...
  'MatchExactly',...
  'NStages',...
  'UseHalfbands',...
  'HalfbandDesignMethod',...
  'Weights',...
  'UpsamplingFactor',...
  'JointOptimization',...
  'Window',...
  'ScalePassband',...
  'StopbandShape',...
  'StopbandDecay',...
  'UniformGrid',...
  'SincFrequencyFactor',...
  'SincPower',...
  'FIRType',...
  'Zerophase',...
  'PassbandOffset',...
  'B1Weights',...
  'B2Weights',...
  'B3Weights',...
  'B4Weights',...
  'B5Weights',...
  'B6Weights',...
  'B7Weights',...
  'B8Weights',...
  'B9Weights',...
  'B10Weights',...
  'B1ForcedFrequencyPoints',...
  'SystemObject'...
  };

% Find the fields that are present in s
fn = fieldnames(s);
inds = cellfun(@(x) find(strcmp(x,b)),fn,'UniformOutput',false);

% Remove the fields from b that aren't present in s
b = b(sort(cell2mat(inds)));

% Special case: b contains MinPhase, MaxPhase, Wpass, Wstop (in that order)
% In this case, reorder these entries
bs = {'MinPhase','Wpass','Wstop','MaxPhase'};
if numel(intersect(bs,b)) == 4
  iM = find(strcmp(b,'MinPhase'));
  b(iM:iM+3) = bs;
end

% Reorder the structure
s = reorderstructure(s,b{:});

% [EOF]