### Question:
HandlerChainBuilder { public List<Handler> sortHandlers(List<Handler> handlers) { final int size = handlers.size(); List<Handler> logicalHandlers = new ArrayList<>(size); List<Handler> protocolHandlers = new ArrayList<>(Math.min(10, size)); for (Handler<?> handler : handlers) { if (handler instanceof LogicalHandler) { logicalHandlers.add(handler); } else { protocolHandlers.add(handler); } } if (!protocolHandlers.isEmpty()) { logicalHandlers.addAll(protocolHandlers); } return logicalHandlers; } HandlerChainBuilder(Bus aBus);  HandlerChainBuilder(); List<Handler> buildHandlerChainFromConfiguration(PortComponentHandlerType hc); List<Handler> buildHandlerChainFromConfiguration(List<PortComponentHandlerType> hc); void setHandlerInitEnabled(boolean b); boolean isHandlerInitEnabled(); List<Handler> sortHandlers(List<Handler> handlers);  }### Answer:
@Test public void testChainSorting() { List<Handler> sortedHandlerChain = builder.sortHandlers(Arrays.asList(allHandlers)); assertSame(logicalHandlers[0], sortedHandlerChain.get(0)); assertSame(logicalHandlers[1], sortedHandlerChain.get(1)); assertSame(protocolHandlers[0], sortedHandlerChain.get(2)); assertSame(protocolHandlers[1], sortedHandlerChain.get(3)); }