Cody

# Problem 70. Alphabetize by last name

Solution 1894242

Submitted on 7 Aug 2019 by Todd Snow
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

alpha_list = 1×3 cell array {'Dagwood Bumstead'} {'Barney Google'} {'Snuffy Smith'} lnam = 'Google' lnam = 'Smith' lnam = 'Bumstead' alpha_list = 1×2 cell array {0×0 double} {'Barney Google'} alpha_list = 1×3 cell array {0×0 double} {'Barney Google'} {'Snuffy Smith'} alpha_list = 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' } lnam = 'Truman' lnam = 'Eisenhower' lnam = 'Kennedy' lnam = 'Johnson' lnam = 'Nixon' lnam = 'Ford' lnam = 'Moler' lnam = 'Reagan' lnam = 'Bush' lnam = 'Clinton' lnam = 'Bush' lnam = 'Obama' alpha_list = 12×1 cell array {0×0 double } {0×0 double } {0×0 double } {0×0 double } {0×0 double } {0×0 double } {0×0 double } {0×0 double } {0×0 double } {0×0 double } {0×0 double } {'Harry Truman'} alpha_list = 12×1 cell array {0×0 double } {0×0 double } {0×0 double } {'Dwight Eisenhower'} {0×0 double } {0×0 double } {0×0 double } {0×0 double } {0×0 double } {0×0 double } {0×0 double } {'Harry Truman' } alpha_list = 12×1 cell array {0×0 double } {0×0 double } {0×0 double } {'Dwight Eisenhower'} {0×0 double } {0×0 double } {'John F. Kennedy' } {0×0 double } {0×0 double } {0×0 double } {0×0 double } {'Harry Truman' } alpha_list = 12×1 cell array {0×0 double } {0×0 double } {0×0 double } {'Dwight Eisenhower'} {0×0 double } {'Lyndon Johnson' } {'John F. Kennedy' } {0×0 double } {0×0 double } {0×0 double } {0×0 double } {'Harry Truman' } alpha_list = 12×1 cell array {0×0 double } {0×0 double } {0×0 double } {'Dwight Eisenhower'} {0×0 double } {'Lyndon Johnson' } {'John F. Kennedy' } {0×0 double } {'Richard Nixon' } {0×0 double } {0×0 double } {'Harry Truman' } alpha_list = 12×1 cell array {0×0 double } {0×0 double } {0×0 double } {'Dwight Eisenhower'} {'Gerald Ford' } {'Lyndon Johnson' } {'John F. Kennedy' } {0×0 double } {'Richard Nixon' } {0×0 double } {0×0 double } {'Harry Truman' } alpha_list = 12×1 cell array {0×0 double } {0×0 double } {0×0 double } {'Dwight Eisenhower'} {'Gerald Ford' } {'Lyndon Johnson' } {'John F. Kennedy' } {'Cleve Moler' } {'Richard Nixon' } {0×0 double } {0×0 double } {'Harry Truman' } alpha_list = 12×1 cell array {0×0 double } {0×0 double } {0×0 double } {'Dwight Eisenhower'} {'Gerald Ford' } {'Lyndon Johnson' } {'John F. Kennedy' } {'Cleve Moler' } {'Richard Nixon' } {0×0 double } {'Ronald Reagan' } {'Harry Truman' } alpha_list = 12×1 cell array {'George Bush' } {0×0 double } {0×0 double } {'Dwight Eisenhower'} {'Gerald Ford' } {'Lyndon Johnson' } {'John F. Kennedy' } {'Cleve Moler' } {'Richard Nixon' } {0×0 double } {'Ronald Reagan' } {'Harry Truman' } alpha_list = 12×1 cell array {'George Bush' } {'George Bush' } {0×0 double } {'Dwight Eisenhower'} {'Gerald Ford' } {'Lyndon Johnson' } {'John F. Kennedy' } {'Cleve Moler' } {'Richard Nixon' } {0×0 double } {'Ronald Reagan' } {'Harry Truman' } 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' } {0×0 double } {'Ronald Reagan' } {'Harry Truman' } 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' } {0×0 double } {'Ronald Reagan' } {'Harry Truman' } 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' } {0×0 double } {'Ronald Reagan' } {'Harry Truman' } 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' }

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!