Cody

Problem 70. Alphabetize by last name

Solution 1866557

Submitted on 5 Jul 2019 by Esraa Mohamed
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'} list2 = 1×3 cell array {0×0 double} {0×0 double} {0×0 double} list2 = 1×3 cell array {'Google Barney'} {0×0 double} {0×0 double} list2 = 1×3 cell array {'Google Barney'} {'Smith Snuffy'} {0×0 double} list2 = 1×3 cell array {'Google Barney'} {'Smith Snuffy'} {'Bumstead Dagwood'} list2 = 1×3 cell array {'Dagwood Bumstead'} {'Google Barney'} {'Smith Snuffy'} list2 = 1×3 cell array {'Dagwood Bumstead'} {'Barney Google'} {'Smith Snuffy'} list2 = 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' } list2 = 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} {0×0 double} list2 = 12×1 cell array {'Truman Harry'} {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 } list2 = 12×1 cell array {'Truman Harry' } {'Eisenhower Dwight'} {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 } list2 = 12×1 cell array {'Truman Harry' } {'Eisenhower Dwight'} {'Kennedy John F.' } {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 } list2 = 12×1 cell array {'Truman Harry' } {'Eisenhower Dwight'} {'Kennedy John F.' } {'Johnson Lyndon' } {0×0 double } {0×0 double } {0×0 double } {0×0 double } {0×0 double } {0×0 double } {0×0 double } {0×0 double } list2 = 12×1 cell array {'Truman Harry' } {'Eisenhower Dwight'} {'Kennedy John F.' } {'Johnson Lyndon' } {'Nixon Richard' } {0×0 double } {0×0 double } {0×0 double } {0×0 double } {0×0 double } {0×0 double } {0×0 double } list2 = 12×1 cell array {'Truman Harry' } {'Eisenhower Dwight'} {'Kennedy John F.' } {'Johnson Lyndon' } {'Nixon Richard' } {'Ford Gerald' } {0×0 double } {0×0 double } {0×0 double } {0×0 double } {0×0 double } {0×0 double } list2 = 12×1 cell array {'Truman Harry' } {'Eisenhower Dwight'} {'Kennedy John F.' } {'Johnson Lyndon' } {'Nixon Richard' } {'Ford Gerald' } {'Moler Cleve' } {0×0 double } {0×0 double } {0×0 double } {0×0 double } {0×0 double } list2 = 12×1 cell array {'Truman Harry' } {'Eisenhower Dwight'} {'Kennedy John F.' } {'Johnson Lyndon' } {'Nixon Richard' } {'Ford Gerald' } {'Moler Cleve' } {'Reagan Ronald' } {0×0 double } {0×0 double } {0×0 double } {0×0 double } list2 = 12×1 cell array {'Truman Harry' } {'Eisenhower Dwight'} {'Kennedy John F.' } {'Johnson Lyndon' } {'Nixon Richard' } {'Ford Gerald' } {'Moler Cleve' } {'Reagan Ronald' } {'Bush George' } {0×0 double } {0×0 double } {0×0 double } list2 = 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' } {0×0 double } {0×0 double } list2 = 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' } {0×0 double } list2 = 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' } list2 = 12×1 cell array {'George Bush' } {'Bush George' } {'Clinton Bill' } {'Eisenhower Dwight'} {'Ford Gerald' } {'Johnson Lyndon' } {'Kennedy John F.' } {'Moler Cleve' } {'Nixon Richard' } {'Obama Barack' } {'Reagan Ronald' } {'Truman Harry' } list2 = 12×1 cell array {'George Bush' } {'George Bush' } {'Clinton Bill' } {'Eisenhower Dwight'} {'Ford Gerald' } {'Johnson Lyndon' } {'Kennedy John F.' } {'Moler Cleve' } {'Nixon Richard' } {'Obama Barack' } {'Reagan Ronald' } {'Truman Harry' } list2 = 12×1 cell array {'George Bush' } {'George Bush' } {'Bill Clinton' } {'Eisenhower Dwight'} {'Ford Gerald' } {'Johnson Lyndon' } {'Kennedy John F.' } {'Moler Cleve' } {'Nixon Richard' } {'Obama Barack' } {'Reagan Ronald' } {'Truman Harry' } list2 = 12×1 cell array {'George Bush' } {'George Bush' } {'Bill Clinton' } {'Dwight Eisenhower'} {'Ford Gerald' } {'Johnson Lyndon' } {'Kennedy John F.' } {'Moler Cleve' } {'Nixon Richard' } {'Obama Barack' } {'Reagan Ronald' } {'Truman Harry' } list2 = 12×1 cell array {'George Bush' } {'George Bush' } {'Bill Clinton' } {'Dwight Eisenhower'} {'Gerald Ford' } {'Johnson Lyndon' } {'Kennedy John F.' } {'Moler Cleve' } {'Nixon Richard' } {'Obama Barack' } {'Reagan Ronald' } {'Truman Harry' } list2 = 12×1 cell array {'George Bush' } {'George Bush' } {'Bill Clinton' } {'Dwight Eisenhower'} {'Gerald Ford' } {'Lyndon Johnson' } {'Kennedy John F.' } {'Moler Cleve' } {'Nixon Richard' } {'Obama Barack' } {'Reagan Ronald' } {'Truman Harry' } list2 = 12×1 cell array {'George Bush' } {'George Bush' } {'Bill Clinton' } {'Dwight Eisenhower'} {'Gerald Ford' } {'Lyndon Johnson' } {'John F. Kennedy' } {'Moler Cleve' } {'Nixon Richard' } {'Obama Barack' } {'Reagan Ronald' } {'Truman Harry' } list2 = 12×1 cell array {'George Bush' } {'George Bush' } {'Bill Clinton' } {'Dwight Eisenhower'} {'Gerald Ford' } {'Lyndon Johnson' } {'John F. Kennedy' } {'Cleve Moler' } {'Nixon Richard' } {'Obama Barack' } {'Reagan Ronald' } {'Truman Harry' } list2 = 12×1 cell array {'George Bush' } {'George Bush' } {'Bill Clinton' } {'Dwight Eisenhower'} {'Gerald Ford' } {'Lyndon Johnson' } {'John F. Kennedy' } {'Cleve Moler' } {'Richard Nixon' } {'Obama Barack' } {'Reagan Ronald' } {'Truman Harry' } list2 = 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' } {'Reagan Ronald' } {'Truman Harry' } list2 = 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' } {'Truman Harry' } list2 = 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' }

Suggested Problems

More from this Author95

Community Treasure Hunt

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

Start Hunting!