content: class Solution {
      // Bucket sort function for each place value digit.
      private void bucketSort(int[] arr, int placeValue) {
          ArrayList<List<Integer>> buckets = new ArrayList<>(10);
          for (int digit = 0; digit < 10; ++digit) {
              buckets.add(digit, new ArrayList<Integer>());
          }
          
          // Store the respective number based on its digit.
          for (int val : arr) {
              int digit = Math.abs(val) / placeValue;
              digit = digit % 10;
              buckets.get(digit).add(val);
          }
  
          // Overwrite 'arr' in sorted order of current place digits.
          int index = 0;
          for (int digit = 0; digit < 10; ++digit) {
              for (int val : buckets.get(digit)) {
                  arr[index] = val;
                  index++;
              }
          }
      }
      
      // Radix sort function.
      private void radixSort(int[] arr) {
          // Find the absolute maximum element to find max number of digits.
          int maxElement = arr[0];
          for (int val : arr) {
              maxElement = Math.max(Math.abs(val), maxElement);
          }
          int maxDigits = 0;
          while (maxElement > 0) {
              maxDigits += 1;
              maxElement /= 10;
          }
  
          // Radix sort, least significant digit place to most significant.
          int placeValue = 1;
          for (int digit = 0; digit < maxDigits; ++digit) {
              bucketSort(arr, placeValue);
              placeValue *= 10;
          }
  
          // Seperate out negatives and reverse them. 
          ArrayList<Integer> negatives = new ArrayList<>();
          ArrayList<Integer> positives = new ArrayList<>();
          for (int val : arr) {
              if (val < 0) {
                  negatives.add(val);
              } else {
                  positives.add(val);
              }
          }
          Collections.reverse(negatives);
  
          // Final 'answer' will be 'negative' elements, then 'positive' elements.
          int index = 0;
          for (int val : negatives) {
              arr[index] = val;
              index++;
          }
          for (int val : positives) {
              arr[index] = val;
              index++;
          }
      }
  
      public int[] sortArray(int[] nums) {
          radixSort(nums);
          return nums;
      }
  }