title: Sorting tags and operation in Swagger Ui
body: <p>In my node.js/express app I wrote documentation using Swagger UI, I want to sort the tags along with the operation alphabetically but it's not working and the default order is being set how do I fix that?</p>
  <pre><code>const swaggerOptions = {
    swaggerDefinition: {
      info: {
        version: &quot;1.0.0&quot;,
        title: &quot;test APIs&quot;,
        description: &quot;test API Information&quot;,
        apisSorter: &quot;alpha&quot;,
        operationsSorter: &quot;alpha&quot;,
        contact: {
          name: &quot;test&quot;,
        },
        servers: [&quot;http://localhost:3000&quot;],
      },
    },
    operationsSorter: (a, b) =&gt; {
      var methodsOrder = [
        &quot;get&quot;,
        &quot;post&quot;,
        &quot;put&quot;,
        &quot;patch&quot;,
        &quot;delete&quot;,
        &quot;options&quot;,
        &quot;trace&quot;,
      ];
      var result =
        methodsOrder.indexOf(a.get(&quot;method&quot;)) -
        methodsOrder.indexOf(b.get(&quot;method&quot;));
  
      if (result === 0) {
        result = a.get(&quot;path&quot;).localeCompare(b.get(&quot;path&quot;));
      }
  
      return result;
    },
    // ['.routes/*.js']
    apis: [&quot;app.js&quot;, &quot;./routes/*.js&quot;],
  };
  
  const swaggerDocs = swaggerJsDoc(swaggerOptions);
  app.use(&quot;/api-docs&quot;, swaggerUi.serve, swaggerUi.setup(swaggerDocs));
  </code></pre>