Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4324642
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:09:37+00:00 2026-05-21T09:09:37+00:00

I have two arrays First array has large number of words, i have 2nd

  • 0

I have two arrays First array has large number of words, i have 2nd array smaller to first array and has some words that are occuring in first array. I need to sort 2nd array based on the order of words in first array.

Ex:-

firstarray = ["a","c","b"...];
2ndarray = ["b","c"...];

2ndarrayaftersort = ["c","b"];

First array is a feature vector and 2nd array is weight vector in SVM classification.

Or i need to sort a string of characters…like

“0 35:1 44:1 10:1 45:1 46:1 4:1 47:1
18:1 48:1 49:1 50:1 51:1 52:1 53:1
54:1 55:1 56:1 57:1 58:1 59:1 60:1
61:1 62:1 6:1 63:1 64:1 65:1 66:1 67:1
19:1 68:1 69:1 70:1 71:1”

In the string above we can see that 10:1 is occuring after 44:1 and so on…i need to see that features are sorted or else Libsvm will not classify correctly.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T09:09:37+00:00Added an answer on May 21, 2026 at 9:09 am

    In each case, you simply need a custom way of comparing any two strings. In the first case, assuming your first array is actually quite large, I’d suggest converting the array to a Dictionary<string, int> so you can efficiently find the right index. Then you’d compare two strings by just finding the corresponding index values and comparing those.

    In the second case you’d need to split the value into two strings, potentially parse both into integers, and compare those values. You may want to convert your array of strings into a collection of parsed values which are easier to compare, then sort, then convert the values back into strings. That will avoid parsing separately for each comparison.

    You can sort an array by passing a custom IComparer<T> or Comparison<T> into Array.Sort.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two arrays the first one has this structure Parameter Keys array array
I have two arrays in PHP. The first array ($author_array) is comprised of user_ids
I have two arrays, each containing strings. The first array is a list of
I know how to sort an array that has two columns: Arrays.sort(myarray, new Comparator<String[]>()
I have two arrays built while parsing a text file. The first contains the
I have two arrays of animals (for example). $array = array( array( 'id' =>
I have two arrays: Array ( [2005] => 0 [2006] => 0 [2007] =>
I have two arrays, one is very large (more than million entries) and other
I have two arrays in php $arrNum = array(1.7, 1.52, 0.01, 0.11); $arrStr =
I have two questions regarding array: First one is regarding following code: int a[30];

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.