diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module
index 3c92450..4939edb 100644
--- a/core/modules/comment/comment.module
+++ b/core/modules/comment/comment.module
@@ -1584,6 +1584,8 @@ function _comment_per_page() {
  * 110, 111, ... , 1zy, 1zz,
  * 2100, 2101, ..., 2zzy, 2zzz,
  * 31000, 31001, ...
+ *
+ * @deprecated Use \Drupal\comment\CommentInterface::intToAlphadecimal() instead.
  */
 function comment_int_to_alphadecimal($i = 0) {
   $num = base_convert((int) $i, 10, 36);
@@ -1595,7 +1597,7 @@ function comment_int_to_alphadecimal($i = 0) {
 /**
  * Decodes a sorting code back to an integer.
  *
- * @see comment_int_to_alphadecimal()
+ * @deprecated Use \Drupal\comment\CommentInterface::alphadecimalToInt() instead.
  */
 function comment_alphadecimal_to_int($c = '00') {
   return base_convert(substr($c, 1), 36, 10);
diff --git a/core/modules/comment/lib/Drupal/comment/CommentInterface.php b/core/modules/comment/lib/Drupal/comment/CommentInterface.php
index 28ec9fb..ef0853a 100644
--- a/core/modules/comment/lib/Drupal/comment/CommentInterface.php
+++ b/core/modules/comment/lib/Drupal/comment/CommentInterface.php
@@ -35,4 +35,40 @@
    */
   public function permalink();
 
+  /**
+   * Generates a sorting code.
+   *
+   * Consists of a leading character indicating length, followed by N digits
+   * with a numerical value in base 36 (alphadecimal). These codes can be sorted
+   * as strings without altering numerical order.
+   *
+   * It goes:
+   * 00, 01, 02, ..., 0y, 0z,
+   * 110, 111, ... , 1zy, 1zz,
+   * 2100, 2101, ..., 2zzy, 2zzz,
+   * 31000, 31001, ...
+   *
+   * @param int $i
+   *   The integer value to convert.
+   *
+   * @return string
+   *   The alpha decimal value.
+   *
+   * @see \Drupal\comment\CommentInterface::alphadecimalToInt
+   */
+  public static function intToAlphadecimal($i = 0);
+
+  /**
+   * Decodes a sorting code back to an integer.
+   *
+   * @param string $c
+   *   The alpha decimal value to convert
+   *
+   * @return int
+   *   The integer value.
+   *
+   * @see \Drupal\comment\CommentInterface::intToAlphadecimal
+   */
+  public static function alphadecimalToInt($c = '00');
+
 }
diff --git a/core/modules/comment/lib/Drupal/comment/Entity/Comment.php b/core/modules/comment/lib/Drupal/comment/Entity/Comment.php
index d2c79bd..49a4384 100644
--- a/core/modules/comment/lib/Drupal/comment/Entity/Comment.php
+++ b/core/modules/comment/lib/Drupal/comment/Entity/Comment.php
@@ -242,7 +242,7 @@ public function preSave(EntityStorageControllerInterface $storage_controller) {
           $max = rtrim($max, '/');
           // We need to get the value at the correct depth.
           $parts = explode('.', $max);
-          $n = comment_alphadecimal_to_int($parts[0]);
+          $n = static::alphadecimalToInt($parts[0]);
           $prefix = '';
         }
         else {
@@ -269,14 +269,14 @@ public function preSave(EntityStorageControllerInterface $storage_controller) {
             // Get the value at the correct depth.
             $parts = explode('.', $max);
             $parent_depth = count(explode('.', $parent->thread->value));
-            $n = comment_alphadecimal_to_int($parts[$parent_depth]);
+            $n = static::alphadecimalToInt($parts[$parent_depth]);
           }
         }
         // Finally, build the thread field for this new comment. To avoid
         // race conditions, get a lock on the thread. If aother process already
         // has the lock, just move to the next integer.
         do {
-          $thread = $prefix . comment_int_to_alphadecimal(++$n) . '/';
+          $thread = $prefix . static::intToAlphadecimal(++$n) . '/';
         } while (!lock()->acquire("comment:{$this->entity_id->value}:$thread"));
         $this->threadLock = $thread;
       }
@@ -462,4 +462,21 @@ public static function preCreate(EntityStorageControllerInterface $storage_contr
     }
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public static function intToAlphadecimal($i = 0) {
+    $num = base_convert((int) $i, 10, 36);
+    $length = strlen($num);
+
+    return chr($length + ord('0') - 1) . $num;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function alphadecimalToInt($c = '00') {
+    return (int) base_convert(substr($c, 1), 36, 10);
+  }
+
 }
diff --git a/core/modules/comment/tests/Drupal/comment/Tests/Entity/CommentStaticTest.php b/core/modules/comment/tests/Drupal/comment/Tests/Entity/CommentStaticTest.php
new file mode 100644
index 0000000..f629ee8
--- /dev/null
+++ b/core/modules/comment/tests/Drupal/comment/Tests/Entity/CommentStaticTest.php
@@ -0,0 +1,68 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\comment\Tests\Entity\CommentStaticTest.
+ */
+
+namespace Drupal\comment\Tests\Entity;
+
+use Drupal\comment\Entity\Comment;
+use Drupal\Tests\UnitTestCase;
+
+/**
+ * Unit tests for the comment entity static functions.
+ *
+ * @group Drupal
+ */
+class CommentStaticTest extends UnitTestCase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function getInfo() {
+    return array(
+      'name' => 'Comment static functions',
+      'description' => 'Test comment static functions.',
+      'group' => 'Comment',
+    );
+  }
+
+  /**
+   * Test the comment entity static functions.
+   *
+   * @param int $value
+   *   The integer value.
+   * @param string $expected
+   *   The expected alphadecimal value.
+   *
+   * @dataProvider providerTestStatic
+   */
+  public function testStatic($value, $expected) {
+    $this->assertSame(Comment::intToAlphadecimal($value), $expected);
+    $this->assertSame($value, Comment::alphadecimalToInt($expected));
+  }
+
+  /**
+   * Data provider for testStatic().
+   *
+   * @see testStatic()
+   *
+   * @return array
+   *   An array containing:
+   *     - The integer value.
+   *     - The alphadecimal value.
+   */
+  public function providerTestStatic() {
+    return array(
+      array(0, '00'),
+      array(1, '01'),
+      array(10, '0a'),
+      array(20, '0k'),
+      array(35, '0z'),
+      array(36, '110'),
+      array(100, '12s'),
+    );
+  }
+
+}
