Java && Beginner Freindly 
Intuitionfirstly , Make two functions
one for Positive Number
second for Negative NumberApproach
get all digits from number (n).
and store digits in Array [nums
# Intuition
firstly , Make two functions 
one for Positive Number
second for Negative Number

# Approach
1. get all digits from number (n).
2. and store digits in Array [nums].
3. sort according to number (n).
4. lastly store all digits in a String(ans).
5. return ans to Long.parseLong(ans.toString());

# Complexity
- Time complexity:
O(n)

- Space complexity:
O(n)

# Code
```java []
class Solution {
    public long smallestNumber(long num) {
        if(num < 10 && num >= 0) return num;
        if(num > -10 && num < 0) return num;
        if(num > 0) return posNum(num);
        return negNum(num);
    }
    public static long posNum(long n){
            int numberlen = String.valueOf(n).length();
            long[] nums = new long[numberlen];
            for(int i=0 ; i <= numberlen ; i++){
                if(n < 10) {
                    nums[i] = n;
                    break;
                }
                long rem = n % 10;
                nums[i] = rem;
                n = n / 10;
            }
            Arrays.sort(nums);
            if(nums[0] == 0){
                for(int i=0;i<nums.length;i++){
                    if(nums[i] != 0){
                        long temp = nums[i];
                        nums[i] = nums[0];
                        nums[0] = temp;
                        break;
                    }
                }
            }
            StringBuilder ans = new StringBuilder();
            for(long num : nums){
                ans.append(num);
            }
            return Long.parseLong(ans.toString());
        }
    public static long negNum(long number){
            int numberlen = String.valueOf(number).length();
                long n = -(number);
                long[] nums = new long[numberlen-1];
                 for(int i=0 ; i <= numberlen-1 ; i++){
                     if(n < 10) {
                         nums[i] = n;
                         break;
                     }
                     long rem = n % 10;
                     nums[i] = rem;
                     n = n / 10;
                 }
                Arrays.sort(nums);
    
                StringBuilder ans = new StringBuilder();
                for(long num : nums){
                    ans.append(num);
                }
                ans.reverse();
                ans.insert(0,'-');
                return Long.parseLong(ans.toString());
        }
}
```
['Java']