code: public static List<SQLiteEntity> orderEntitiesList(SQLiteDatabaseSchema schema) {
  		List<SQLiteEntity> entities = schema.getEntitiesAsList();
  		Collections.sort(entities, new Comparator<SQLiteEntity>() {
  
  			@Override
  			public int compare(SQLiteEntity lhs, SQLiteEntity rhs) {
  				return lhs.getTableName().compareTo(rhs.getTableName());
  			}
  		});
  
  		List<SQLiteEntity> list = schema.getEntitiesAsList();
  
  		EntitySorter<SQLiteEntity> sorder = new EntitySorter<SQLiteEntity>(list) {
  
  			@Override
  			public Collection<SQLiteEntity> getDependencies(SQLiteEntity item) {
  				return item.referedEntities;
  			}
  
  			@Override
  			public void generateError(SQLiteEntity item) {
  				throw new CircularRelationshipException(item);
  			}
  		};
  
  		return sorder.order();
  	}
docs: Generate ordered entities list.
  
  @param schema
  the schema
  @return the list