Cody

# Problem 70. Alphabetize by last name

Solution 1606845

Submitted on 11 Aug 2018 by Shawn Neal
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×1 cell array {'Google Barney'} list1 = 1×2 cell array {'Google Barney'} {'Smith Snuffy'} list1 = 1×3 cell array {'Google Barney'} {'Smith Snuffy'} {'Bumstead Dagwood'} list2 = 1×3 cell array {'Bumstead Dagwood'} {'Google Barney'} {'Smith Snuffy'} alpha_list = 1×1 cell array {'Dagwood Bumstead'} alpha_list = 1×2 cell array {'Dagwood Bumstead'} {'Barney Google'} alpha_list = 1×3 cell array {'Dagwood Bumstead'} {'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' } list1 = 1×1 cell array {'Truman Harry'} list1 = 1×2 cell array {'Truman Harry'} {'Eisenhower Dwight'} list1 = 1×3 cell array {'Truman Harry'} {'Eisenhower Dwight'} {'Kennedy John F.'} list1 = 1×4 cell array {'Truman Harry'} {'Eisenhower Dwight'} {'Kennedy John F.'} {'Johnson Lyndon'} list1 = 1×5 cell array {'Truman Harry'} {'Eisenhower Dwight'} {'Kennedy John F.'} {'Johnson Lyndon'} {'Nixon Richard'} list1 = 1×6 cell array {'Truman Harry'} {'Eisenhower Dwight'} {'Kennedy John F.'} {'Johnson Lyndon'} {'Nixon Richard'} {'Ford Gerald'} list1 = 1×7 cell array {'Truman Harry'} {'Eisenhower Dwight'} {'Kennedy John F.'} {'Johnson Lyndon'} {'Nixon Richard'} {'Ford Gerald'} {'Moler Cleve'} list1 = 1×8 cell array {'Truman Harry'} {'Eisenhower Dwight'} {'Kennedy John F.'} {'Johnson Lyndon'} {'Nixon Richard'} {'Ford Gerald'} {'Moler Cleve'} {'Reagan Ronald'} list1 = 1×9 cell array Columns 1 through 8 {'Truman Harry'} {'Eisenhower Dwight'} {'Kennedy John F.'} {'Johnson Lyndon'} {'Nixon Richard'} {'Ford Gerald'} {'Moler Cleve'} {'Reagan Ronald'} Column 9 {'Bush George'} list1 = 1×10 cell array Columns 1 through 8 {'Truman Harry'} {'Eisenhower Dwight'} {'Kennedy John F.'} {'Johnson Lyndon'} {'Nixon Richard'} {'Ford Gerald'} {'Moler Cleve'} {'Reagan Ronald'} Columns 9 through 10 {'Bush George'} {'Clinton Bill'} list1 = 1×11 cell array Columns 1 through 8 {'Truman Harry'} {'Eisenhower Dwight'} {'Kennedy John F.'} {'Johnson Lyndon'} {'Nixon Richard'} {'Ford Gerald'} {'Moler Cleve'} {'Reagan Ronald'} Columns 9 through 11 {'Bush George'} {'Clinton Bill'} {'Bush George'} list1 = 1×12 cell array Columns 1 through 8 {'Truman Harry'} {'Eisenhower Dwight'} {'Kennedy John F.'} {'Johnson Lyndon'} {'Nixon Richard'} {'Ford Gerald'} {'Moler Cleve'} {'Reagan Ronald'} Columns 9 through 12 {'Bush George'} {'Clinton Bill'} {'Bush George'} {'Obama Barack'} list2 = 1×12 cell array Columns 1 through 8 {'Bush George'} {'Bush George'} {'Clinton Bill'} {'Eisenhower Dwight'} {'Ford Gerald'} {'Johnson Lyndon'} {'Kennedy John F.'} {'Moler Cleve'} Columns 9 through 12 {'Nixon Richard'} {'Obama Barack'} {'Reagan Ronald'} {'Truman Harry'} alpha_list = 1×1 cell array {'George Bush'} alpha_list = 1×2 cell array {'George Bush'} {'George Bush'} alpha_list = 1×3 cell array {'George Bush'} {'George Bush'} {'Bill Clinton'} alpha_list = 1×4 cell array {'George Bush'} {'George Bush'} {'Bill Clinton'} {'Dwight Eisenhower'} alpha_list = 1×5 cell array {'George Bush'} {'George Bush'} {'Bill Clinton'} {'Dwight Eisenhower'} {'Gerald Ford'} alpha_list = 1×6 cell array {'George Bush'} {'George Bush'} {'Bill Clinton'} {'Dwight Eisenhower'} {'Gerald Ford'} {'Lyndon Johnson'} alpha_list = 1×7 cell array {'George Bush'} {'George Bush'} {'Bill Clinton'} {'Dwight Eisenhower'} {'Gerald Ford'} {'Lyndon Johnson'} {'John F. Kennedy'} alpha_list = 1×8 cell array {'George Bush'} {'George Bush'} {'Bill Clinton'} {'Dwight Eisenhower'} {'Gerald Ford'} {'Lyndon Johnson'} {'John F. Kennedy'} {'Cleve Moler'} alpha_list = 1×9 cell array Columns 1 through 8 {'George Bush'} {'George Bush'} {'Bill Clinton'} {'Dwight Eisenhower'} {'Gerald Ford'} {'Lyndon Johnson'} {'John F. Kennedy'} {'Cleve Moler'} Column 9 {'Richard Nixon'} alpha_list = 1×10 cell array Columns 1 through 8 {'George Bush'} {'George Bush'} {'Bill Clinton'} {'Dwight Eisenhower'} {'Gerald Ford'} {'Lyndon Johnson'} {'John F. Kennedy'} {'Cleve Moler'} Columns 9 through 10 {'Richard Nixon'} {'Barack Obama'} alpha_list = 1×11 cell array Columns 1 through 8 {'George Bush'} {'George Bush'} {'Bill Clinton'} {'Dwight Eisenhower'} {'Gerald Ford'} {'Lyndon Johnson'} {'John F. Kennedy'} {'Cleve Moler'} Columns 9 through 11 {'Richard Nixon'} {'Barack Obama'} {'Ronald Reagan'} alpha_list = 1×12 cell array Columns 1 through 8 {'George Bush'} {'George Bush'} {'Bill Clinton'} {'Dwight Eisenhower'} {'Gerald Ford'} {'Lyndon Johnson'} {'John F. Kennedy'} {'Cleve Moler'} Columns 9 through 12 {'Richard Nixon'} {'Barack Obama'} {'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' }