Untitled
unknown
javascript
2 years ago
723 B
5
Indexable
Never
List<String> places = Arrays.asList("1.00 STAR", "10.00 STAR", "200.00 STAR", "24.67 STAR", "Not For Sale", "Not For Sale"); List<Float> price = new ArrayList<>(); DecimalFormat df = new DecimalFormat("0.00"); df.setMaximumFractionDigits(2); for (String s : places) { s = s.replaceAll("[\\s,a-zA-Z]", ""); if (!s.equals("")) { float number = Float.parseFloat(s); df.format(number); price.add(Float.valueOf(df.format(number))); } } List<Float> sortedList = price.stream().sorted().collect(Collectors.toList()); sortedList.forEach(System.out::println); }