Cody

# Problem 70. Alphabetize by last name

Solution 1847793

Submitted on 12 Jun 2019 by Ankit Kumar Mishra
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

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' } m = 12 n = 1 alpha_list = 12×1 cell array {'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' } k = 2×1 cell array {'Harry' } {'Truman'} alpha_list = 12×1 cell array {'Truman' } {'Dwight Eisenhower'} {'John F. Kennedy' } {'Lyndon Johnson' } {'Richard Nixon' } {'Gerald Ford' } {'Cleve Moler' } {'Ronald Reagan' } {'George Bush' } {'Bill Clinton' } {'George Bush' } {'Barack Obama' } k = 2×1 cell array {'Dwight' } {'Eisenhower'} alpha_list = 12×1 cell array {'Truman' } {'Eisenhower' } {'John F. Kennedy'} {'Lyndon Johnson' } {'Richard Nixon' } {'Gerald Ford' } {'Cleve Moler' } {'Ronald Reagan' } {'George Bush' } {'Bill Clinton' } {'George Bush' } {'Barack Obama' } k = 3×1 cell array {'John' } {'F.' } {'Kennedy'} alpha_list = 12×1 cell array {'Truman' } {'Eisenhower' } {'Kennedy' } {'Lyndon Johnson'} {'Richard Nixon' } {'Gerald Ford' } {'Cleve Moler' } {'Ronald Reagan' } {'George Bush' } {'Bill Clinton' } {'George Bush' } {'Barack Obama' } k = 2×1 cell array {'Lyndon' } {'Johnson'} alpha_list = 12×1 cell array {'Truman' } {'Eisenhower' } {'Kennedy' } {'Johnson' } {'Richard Nixon'} {'Gerald Ford' } {'Cleve Moler' } {'Ronald Reagan'} {'George Bush' } {'Bill Clinton' } {'George Bush' } {'Barack Obama' } k = 2×1 cell array {'Richard'} {'Nixon' } alpha_list = 12×1 cell array {'Truman' } {'Eisenhower' } {'Kennedy' } {'Johnson' } {'Nixon' } {'Gerald Ford' } {'Cleve Moler' } {'Ronald Reagan'} {'George Bush' } {'Bill Clinton' } {'George Bush' } {'Barack Obama' } k = 2×1 cell array {'Gerald'} {'Ford' } alpha_list = 12×1 cell array {'Truman' } {'Eisenhower' } {'Kennedy' } {'Johnson' } {'Nixon' } {'Ford' } {'Cleve Moler' } {'Ronald Reagan'} {'George Bush' } {'Bill Clinton' } {'George Bush' } {'Barack Obama' } k = 2×1 cell array {'Cleve'} {'Moler'} alpha_list = 12×1 cell array {'Truman' } {'Eisenhower' } {'Kennedy' } {'Johnson' } {'Nixon' } {'Ford' } {'Moler' } {'Ronald Reagan'} {'George Bush' } {'Bill Clinton' } {'George Bush' } {'Barack Obama' } k = 2×1 cell array {'Ronald'} {'Reagan'} alpha_list = 12×1 cell array {'Truman' } {'Eisenhower' } {'Kennedy' } {'Johnson' } {'Nixon' } {'Ford' } {'Moler' } {'Reagan' } {'George Bush' } {'Bill Clinton'} {'George Bush' } {'Barack Obama'} k = 2×1 cell array {'George'} {'Bush' } alpha_list = 12×1 cell array {'Truman' } {'Eisenhower' } {'Kennedy' } {'Johnson' } {'Nixon' } {'Ford' } {'Moler' } {'Reagan' } {'Bush' } {'Bill Clinton'} {'George Bush' } {'Barack Obama'} k = 2×1 cell array {'Bill' } {'Clinton'} alpha_list = 12×1 cell array {'Truman' } {'Eisenhower' } {'Kennedy' } {'Johnson' } {'Nixon' } {'Ford' } {'Moler' } {'Reagan' } {'Bush' } {'Clinton' } {'George Bush' } {'Barack Obama'} k = 2×1 cell array {'George'} {'Bush' } alpha_list = 12×1 cell array {'Truman' } {'Eisenhower' } {'Kennedy' } {'Johnson' } {'Nixon' } {'Ford' } {'Moler' } {'Reagan' } {'Bush' } {'Clinton' } {'Bush' } {'Barack Obama'} k = 2×1 cell array {'Barack'} {'Obama' } alpha_list = 12×1 cell array {'Truman' } {'Eisenhower'} {'Kennedy' } {'Johnson' } {'Nixon' } {'Ford' } {'Moler' } {'Reagan' } {'Bush' } {'Clinton' } {'Bush' } {'Obama' } alph_list = 12×1 cell array {'Bush' } {'Bush' } {'Clinton' } {'Eisenhower'} {'Ford' } {'Johnson' } {'Kennedy' } {'Moler' } {'Nixon' } {'Obama' } {'Reagan' } {'Truman' } I = 9 11 10 2 6 4 3 7 5 12 8 1 alpha_list = 12×1 cell array {'George Bush'} {'Eisenhower' } {'Kennedy' } {'Johnson' } {'Nixon' } {'Ford' } {'Moler' } {'Reagan' } {'Bush' } {'Clinton' } {'Bush' } {'Obama' } alpha_list = 12×1 cell array {'George Bush'} {'George Bush'} {'Kennedy' } {'Johnson' } {'Nixon' } {'Ford' } {'Moler' } {'Reagan' } {'Bush' } {'Clinton' } {'Bush' } {'Obama' } alpha_list = 12×1 cell array {'George Bush' } {'George Bush' } {'Bill Clinton'} {'Johnson' } {'Nixon' } {'Ford' } {'Moler' } {'Reagan' } {'Bush' } {'Clinton' } {'Bush' } {'Obama' } alpha_list = 12×1 cell array {'George Bush' } {'George Bush' } {'Bill Clinton' } {'Dwight Eisenhower'} {'Nixon' } {'Ford' } {'Moler' } {'Reagan' } {'Bush' } {'Clinton' } {'Bush' } {'Obama' } alpha_list = 12×1 cell array {'George Bush' } {'George Bush' } {'Bill Clinton' } {'Dwight Eisenhower'} {'Gerald Ford' } {'Ford' } {'Moler' } {'Reagan' } {'Bush' } {'Clinton' } {'Bush' } {'Obama' } alpha_list = 12×1 cell array {'George Bush' } {'George Bush' } {'Bill Clinton' } {'Dwight Eisenhower'} {'Gerald Ford' } {'Lyndon Johnson' } {'Moler' } {'Reagan' } {'Bush' } {'Clinton' } {'Bush' } {'Obama' } alpha_list = 12×1 cell array {'George Bush' } {'George Bush' } {'Bill Clinton' } {'Dwight Eisenhower'} {'Gerald Ford' } {'Lyndon Johnson' } {'John F. Kennedy' } {'Reagan' } {'Bush' } {'Clinton' } {'Bush' } {'Obama' } alpha_list = 12×1 cell array {'George Bush' } {'George Bush' } {'Bill Clinton' } {'Dwight Eisenhower'} {'Gerald Ford' } {'Lyndon Johnson' } {'John F. Kennedy' } {'Cleve Moler' } {'Bush' } {'Clinton' } {'Bush' } {'Obama' } 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' } {'Clinton' } {'Bush' } {'Obama' } 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' } {'Bush' } {'Obama' } 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' } {'Obama' } 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' }