### Question:
OverlayRenderer extends MouseListener implements KeyListener { static void sortOverlays(List<Overlay> overlays) { overlays.sort((a, b) -> { if (a.getPosition() != b.getPosition()) { return a.getPosition().compareTo(b.getPosition()); } return a.getPosition() == OverlayPosition.DYNAMIC ? a.getPriority().compareTo(b.getPriority()) : b.getPriority().compareTo(a.getPriority()); }); } @Inject private  OverlayRenderer(
		final Provider<Client> clientProvider,
		final PluginManager pluginManager,
		final MouseManager mouseManager,
		final KeyManager keyManager,
		final TooltipOverlay tooltipOverlay,
		final InfoBoxOverlay infoBoxOverlay,
		final WorldMapOverlay worldMapOverlay,
		final ConfigManager configManager,
		final RuneLiteConfig runeLiteConfig); @Subscribe void onGameStateChanged(GameStateChanged event); @Subscribe void onPluginChanged(PluginChanged event); @Subscribe void onFocusChanged(FocusChanged event); void render(Graphics2D graphics, final OverlayLayer layer); @Override MouseEvent mousePressed(MouseEvent mouseEvent); @Override MouseEvent mouseDragged(MouseEvent mouseEvent); @Override MouseEvent mouseReleased(MouseEvent mouseEvent); @Override void keyTyped(KeyEvent e); @Override void keyPressed(KeyEvent e); @Override void keyReleased(KeyEvent e);  }### Answer:
@Test public void testSort() { Overlay tlh = new TestOverlay(OverlayPosition.TOP_LEFT, OverlayPriority.HIGH); Overlay tll = new TestOverlay(OverlayPosition.TOP_LEFT, OverlayPriority.LOW); List<Overlay> overlays = Arrays.asList(tlh, tll); OverlayRenderer.sortOverlays(overlays); assertEquals(tlh, overlays.get(0)); assertEquals(tll, overlays.get(1)); }
@Test public void testSortDynamic() { Overlay tlh = new TestOverlay(OverlayPosition.TOP_LEFT, OverlayPriority.HIGH); Overlay dyn = new TestOverlay(OverlayPosition.DYNAMIC, OverlayPriority.HIGH); List<Overlay> overlays = Arrays.asList(tlh, dyn); OverlayRenderer.sortOverlays(overlays); assertEquals(dyn, overlays.get(0)); assertEquals(tlh, overlays.get(1)); }
@Test public void testTooltips() { Overlay t = new TestOverlay(OverlayPosition.TOOLTIP, OverlayPriority.HIGH); Overlay dyn = new TestOverlay(OverlayPosition.DYNAMIC, OverlayPriority.HIGH); Overlay tlh = new TestOverlay(OverlayPosition.TOP_LEFT, OverlayPriority.HIGH); List<Overlay> overlays = Arrays.asList(t, dyn, tlh); OverlayRenderer.sortOverlays(overlays); assertEquals(dyn, overlays.get(0)); assertEquals(tlh, overlays.get(1)); assertEquals(t, overlays.get(2)); }