New to coding need help with this dirty bruteforce approach
Sorry for the dirty code below but I don\'t know much about DS and ALGO so all I have is bruteforce and dirty code.\nBut can you please help me where this code 
Sorry for the dirty code below but I don\'t know much about DS and ALGO so all I have is bruteforce and dirty code.\nBut can you please help me where this code went wrong.\n```\nclass Solution {\n    public long smallestNumber(long num) {\n        if(num<0){\n            long ref=(-1)*num;\n            int len=0;\n        while(ref>0){\n            len++;\n            ref/=10;\n        }\n        ref=num;\n        long [] test= new long[len];\n        for(int i=0;i<len;i++){\n            test[i]=ref%10;\n            ref/=10;\n        }\n        Arrays.sort(test);\n        ref=0;\n        int tomultiply=1;\n        for(int i=test.length-1;i>=0;i--){\n            ref=test[i]*tomultiply+ref;\n            tomultiply*=10;\n        }\n        return ref;\n        }\n        else if(num>=0){\n                 long ref=num;\n            int len=0;\n        while(ref>0){\n            len++;\n            ref/=10;\n        }\n        ref=num;\n            long [] test= new long[len];\n        for(int i=0;i<len;i++){\n            test[i]=ref%10;\n            ref/=10;\n        }\n        Arrays.sort(test);\n            int countOfZero=0;\n        for(int i=0;i<len;i++){\n            if(test[i]==0) countOfZero++;\n            break;\n        }\n        long [] lmao = new long[len];\n            lmao[0]=test[countOfZero];\n            for(int i=1;i<=countOfZero;i++){\n                lmao[i]=0;\n            }\n            for(int i=countOfZero+1;i<len;i++){\n                lmao[i]=test[i];\n            }\n            ref=0;\n        int tomultiply=1;\n        for(int i=lmao.length-1;i>=0;i--){\n            ref=lmao[i]*tomultiply+ref;\n            tomultiply*=10;\n        }\n        return ref;\n            \n        }\n        return 80085;\n        \n    }\n}\n```
['Java']