Cody

# Problem 70. Alphabetize by last name

Solution 1853185

Submitted on 19 Jun 2019 by Albit
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
list = {'Barney Google','Snuffy Smith','Dagwood Bumstead'}; alpha_list = {'Dagwood Bumstead','Barney Google','Snuffy Smith'} assert(isequal(alphabetize(list),alpha_list))

alpha_list = 1×3 cell array {'Dagwood Bumstead'} {'Barney Google'} {'Snuffy Smith'} list1 = 1×3 cell array {'Google Barney'} {'Smith Snuffy'} {'Bumstead Dagwood'} a = 1×3 cell array {'Bumstead Dagwood'} {'Google Barney'} {'Smith Snuffy'} index = 3 1 2 b = 1×3 cell array {'Dagwood Bumstead'} {'Barney Google'} {'Snuffy Smith'}

2   Pass
list = {'Harry Truman' 'Dwight Eisenhower' 'John F. Kennedy' 'Lyndon Johnson' 'Richard Nixon' 'Gerald Ford' 'Cleve Moler' 'Ronald Reagan' 'George Bush' 'Bill Clinton' 'George Bush' 'Barack Obama'}; alpha_list = {'George Bush' 'George Bush' 'Bill Clinton' 'Dwight Eisenhower' 'Gerald Ford' 'Lyndon Johnson' 'John F. Kennedy' 'Cleve Moler' 'Richard Nixon' 'Barack Obama' 'Ronald Reagan' 'Harry Truman'} assert(isequal(alphabetize(list),alpha_list))

alpha_list = 12×1 cell array {'George Bush' } {'George Bush' } {'Bill Clinton' } {'Dwight Eisenhower'} {'Gerald Ford' } {'Lyndon Johnson' } {'John F. Kennedy' } {'Cleve Moler' } {'Richard Nixon' } {'Barack Obama' } {'Ronald Reagan' } {'Harry Truman' } list1 = 12×1 cell array {'Truman Harry' } {'Eisenhower Dwight'} {'Kennedy John F.' } {'Johnson Lyndon' } {'Nixon Richard' } {'Ford Gerald' } {'Moler Cleve' } {'Reagan Ronald' } {'Bush George' } {'Clinton Bill' } {'Bush George' } {'Obama Barack' } a = 12×1 cell array {'Bush George' } {'Bush George' } {'Clinton Bill' } {'Eisenhower Dwight'} {'Ford Gerald' } {'Johnson Lyndon' } {'Kennedy John F.' } {'Moler Cleve' } {'Nixon Richard' } {'Obama Barack' } {'Reagan Ronald' } {'Truman Harry' } index = 9 11 10 2 6 4 3 7 5 12 8 1 b = 12×1 cell array {'George Bush' } {'George Bush' } {'Bill Clinton' } {'Dwight Eisenhower'} {'Gerald Ford' } {'Lyndon Johnson' } {'John F. Kennedy' } {'Cleve Moler' } {'Richard Nixon' } {'Barack Obama' } {'Ronald Reagan' } {'Harry Truman' }