Former US presidents Barack Obama and Donald Trump sat next to each at the state funeral service for Jimmy Carter.