plugins types FEATURE sort callback in bits
diff --git a/src/plugins_types.h b/src/plugins_types.h
index d0027e0..66ba18e 100644
--- a/src/plugins_types.h
+++ b/src/plugins_types.h
@@ -744,6 +744,12 @@
         const struct lyd_value *val2);
 
 /**
+ * @brief Implementation of the ::lyplg_type_sort_clb for the built-in bits type.
+ */
+LIBYANG_API_DEF int lyplg_type_sort_bits(const struct ly_ctx *ctx, const struct lyd_value *val1,
+        const struct lyd_value *val2);
+
+/**
  * @brief Implementation of the ::lyplg_type_print_clb for the built-in bits type.
  */
 LIBYANG_API_DECL const void *lyplg_type_print_bits(const struct ly_ctx *ctx, const struct lyd_value *value,
diff --git a/src/plugins_types/bits.c b/src/plugins_types/bits.c
index 44736da..badf2b1 100644
--- a/src/plugins_types/bits.c
+++ b/src/plugins_types/bits.c
@@ -382,6 +382,21 @@
     return LY_SUCCESS;
 }
 
+LIBYANG_API_DEF int
+lyplg_type_sort_bits(const struct ly_ctx *UNUSED(ctx), const struct lyd_value *val1, const struct lyd_value *val2)
+{
+    struct lyd_value_binary *v1, *v2;
+    struct lysc_type_bits *type_bits = (struct lysc_type_bits *)val1->realtype;
+    int cmp;
+
+    LYD_VALUE_GET(val1, v1);
+    LYD_VALUE_GET(val2, v2);
+
+    cmp = memcmp(v1->data, v2->data, lyplg_type_bits_bitmap_size(type_bits));
+
+    return cmp;
+}
+
 LIBYANG_API_DEF const void *
 lyplg_type_print_bits(const struct ly_ctx *ctx, const struct lyd_value *value, LY_VALUE_FORMAT format,
         void *UNUSED(prefix_data), ly_bool *dynamic, size_t *value_len)
@@ -496,7 +511,7 @@
         .plugin.store = lyplg_type_store_bits,
         .plugin.validate = NULL,
         .plugin.compare = lyplg_type_compare_bits,
-        .plugin.sort = NULL,
+        .plugin.sort = lyplg_type_sort_bits,
         .plugin.print = lyplg_type_print_bits,
         .plugin.duplicate = lyplg_type_dup_bits,
         .plugin.free = lyplg_type_free_bits,
diff --git a/tests/utests/types/bits.c b/tests/utests/types/bits.c
index 11b9208..ddf8143 100644
--- a/tests/utests/types/bits.c
+++ b/tests/utests/types/bits.c
@@ -952,6 +952,42 @@
 }
 
 static void
+test_plugin_sort(void **state)
+{
+    const char *schema;
+    struct lys_module *mod;
+    struct lyplg_type *type = lyplg_type_plugin_find("", NULL, ly_data_type2str[LY_TYPE_BITS]);
+    struct lysc_type *lysc_type;
+    struct ly_err_item *err = NULL;
+    struct lyd_value val1 = {0}, val2 = {0};
+
+    schema = MODULE_CREATE_YANG("T0", "leaf-list ll { type bits { bit zero; bit one; bit two; bit three;}}");
+    UTEST_ADD_MODULE(schema, LYS_IN_YANG, NULL, &mod);
+    lysc_type = ((struct lysc_node_leaf *)mod->compiled->data)->type;
+
+    /* 1000 < 1001 */
+    assert_int_equal(LY_SUCCESS, type->store(UTEST_LYCTX, lysc_type, "three", strlen("three"),
+            0, LY_VALUE_XML, NULL, LYD_VALHINT_STRING, NULL, &val1, NULL, &err));
+    assert_int_equal(LY_SUCCESS, type->store(UTEST_LYCTX, lysc_type, "three one", strlen("three one"),
+            0, LY_VALUE_XML, NULL, LYD_VALHINT_STRING, NULL, &val2, NULL, &err));
+    assert_true(0 > type->sort(UTEST_LYCTX, &val1, &val2));
+    assert_true(0 < type->sort(UTEST_LYCTX, &val2, &val1));
+    assert_int_equal(0, type->sort(UTEST_LYCTX, &val1, &val1));
+    type->free(UTEST_LYCTX, &val1);
+    type->free(UTEST_LYCTX, &val2);
+
+    /* 0011 == 0011 */
+    assert_int_equal(LY_SUCCESS, type->store(UTEST_LYCTX, lysc_type, "zero one", strlen("zero one"),
+            0, LY_VALUE_XML, NULL, LYD_VALHINT_STRING, NULL, &val1, NULL, &err));
+    assert_int_equal(LY_SUCCESS, type->store(UTEST_LYCTX, lysc_type, "one zero", strlen("one zero"),
+            0, LY_VALUE_XML, NULL, LYD_VALHINT_STRING, NULL, &val2, NULL, &err));
+    assert_int_equal(0, type->sort(UTEST_LYCTX, &val1, &val2));
+    assert_int_equal(0, type->sort(UTEST_LYCTX, &val2, &val1));
+    type->free(UTEST_LYCTX, &val1);
+    type->free(UTEST_LYCTX, &val2);
+}
+
+static void
 test_plugin_print(void **state)
 {
     struct ly_err_item *err = NULL;
@@ -1076,6 +1112,7 @@
 
         UTEST(test_plugin_store),
         UTEST(test_plugin_compare),
+        UTEST(test_plugin_sort),
         UTEST(test_plugin_print),
         UTEST(test_plugin_dup),
     };